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

Default header and footer margins (in inches)

DEFAULT_LEFT_RIGHT

Default left and right margin (in inches)

DEFAULT_TOP_BOTTOM

Default top and bottom margins (in inches)

Attributes

bottom[R]

Bottom margin (in inches) @return [Float]

header[R]

Header margin (in inches) @return [Float]

left[R]

Left margin (in inches) @return [Float]

right[R]

Right margin (in inches) @return [Float]

top[R]

Top margin (in inches) @return [Float]

Public Class Methods

new(options={}) click to toggle source

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

bottom=(v) click to toggle source

@see bottom

# File lib/axlsx/workbook/worksheet/page_margins.rb, line 82
def bottom=(v); Axlsx::validate_unsigned_numeric(v); @bottom = v end
header=(v) click to toggle source

@see header

# File lib/axlsx/workbook/worksheet/page_margins.rb, line 84
def header=(v); Axlsx::validate_unsigned_numeric(v); @header = v end
left=(v) click to toggle source

@see left

# File lib/axlsx/workbook/worksheet/page_margins.rb, line 76
def left=(v); Axlsx::validate_unsigned_numeric(v); @left = v end
right=(v) click to toggle source

@see right

# File lib/axlsx/workbook/worksheet/page_margins.rb, line 78
def right=(v); Axlsx::validate_unsigned_numeric(v); @right = v end
set(margins) click to toggle source

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
to_xml_string(str = '') click to toggle source

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
top=(v) click to toggle source

@see top

# File lib/axlsx/workbook/worksheet/page_margins.rb, line 80
def top=(v); Axlsx::validate_unsigned_numeric(v); @top = v end