class Axlsx::PageMargins
PageMargins
specify the margins when printing a worksheet.
For compatibility, PageMargins
serialize to an empty string, unless at least one custom margin value has been specified. Otherwise, it serializes to a PageMargin element specifying all 6 margin values (using default values for margins that have not been specified explicitly).
@note The recommended way to manage page margins is via Worksheet#page_margins
@see Worksheet#page_margins
@see Worksheet#initialize
Constants
Attributes
Bottom margin (in inches) @return [Float]
Header margin (in inches) @return [Float]
Left margin (in inches) @return [Float]
Right margin (in inches) @return [Float]
Top margin (in inches) @return [Float]
Public Class Methods
Creates a new PageMargins
object @option options [Numeric] left The left margin in inches @option options [Numeric] right The right margin in inches @option options [Numeric] bottom The bottom margin in inches @option options [Numeric] top The top margin in inches @option options [Numeric] header The header margin in inches @option options [Numeric] footer The footer margin in inches
# File lib/axlsx/workbook/worksheet/page_margins.rb, line 23 def initialize(options={}) # Default values taken from MS Excel for Mac 2011 @left = @right = DEFAULT_LEFT_RIGHT @top = @bottom = DEFAULT_TOP_BOTTOM @header = @footer = DEFAULT_HEADER_FOOTER parse_options options end
Public Instance Methods
@see bottom
# File lib/axlsx/workbook/worksheet/page_margins.rb, line 82 def bottom=(v); Axlsx::validate_unsigned_numeric(v); @bottom = v end
@see header
# File lib/axlsx/workbook/worksheet/page_margins.rb, line 84 def header=(v); Axlsx::validate_unsigned_numeric(v); @header = v end
@see left
# File lib/axlsx/workbook/worksheet/page_margins.rb, line 76 def left=(v); Axlsx::validate_unsigned_numeric(v); @left = v end
@see right
# File lib/axlsx/workbook/worksheet/page_margins.rb, line 78 def right=(v); Axlsx::validate_unsigned_numeric(v); @right = v end
Set some or all margins at once. @param [Hash] margins the margins to set (possible keys are :left, :right, :top, :bottom, :header and :footer).
# File lib/axlsx/workbook/worksheet/page_margins.rb, line 68 def set(margins) margins.select do |k, v| next unless [:left, :right, :top, :bottom, :header, :footer].include? k send("#{k}=", v) end end
Serializes the page margins element @param [String] str @return [String] @note For compatibility, this is a noop unless custom margins have been specified. @see custom_margins_specified?
# File lib/axlsx/workbook/worksheet/page_margins.rb, line 93 def to_xml_string(str = '') serialized_tag('pageMargins', str) end
@see top
# File lib/axlsx/workbook/worksheet/page_margins.rb, line 80 def top=(v); Axlsx::validate_unsigned_numeric(v); @top = v end