Class: Axlsx::PageMargins
- Inherits:
-
Object
- Object
- Axlsx::PageMargins
- Includes:
- OptionsParser, SerializedAttributes
- Defined in:
- lib/axlsx/workbook/worksheet/page_margins.rb
Overview
The recommended way to manage page margins is via Worksheet#page_margins
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).
Constant Summary collapse
- DEFAULT_LEFT_RIGHT =
Default left and right margin (in inches)
0.75
- DEFAULT_TOP_BOTTOM =
Default top and bottom margins (in inches)
1.00
- DEFAULT_HEADER_FOOTER =
Default header and footer margins (in inches)
0.50
Instance Attribute Summary collapse
-
#bottom ⇒ Float
Bottom margin (in inches).
-
#footer ⇒ Float
Footer margin (in inches).
-
#header ⇒ Float
Header margin (in inches).
-
#left ⇒ Float
Left margin (in inches).
-
#right ⇒ Float
Right margin (in inches).
-
#top ⇒ Float
Top margin (in inches).
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ PageMargins
constructor
Creates a new PageMargins object.
-
#set(margins) ⇒ Object
Set some or all margins at once.
-
#to_xml_string(str = '') ⇒ String
Serializes the page margins element.
Methods included from SerializedAttributes
#declared_attributes, included, #serialized_attributes, #serialized_element_attributes, #serialized_tag
Methods included from OptionsParser
Constructor Details
#initialize(options = {}) ⇒ PageMargins
Creates a new PageMargins object
22 23 24 25 26 27 28 |
# File 'lib/axlsx/workbook/worksheet/page_margins.rb', line 22 def initialize( = {}) # Default values taken from MS Excel for Mac 2011 @left = @right = DEFAULT_LEFT_RIGHT @top = @bottom = DEFAULT_TOP_BOTTOM @header = @footer = DEFAULT_HEADER_FOOTER end |
Instance Attribute Details
#bottom ⇒ Float
Bottom margin (in inches)
55 56 57 |
# File 'lib/axlsx/workbook/worksheet/page_margins.rb', line 55 def bottom @bottom end |
#footer ⇒ Float
Footer margin (in inches)
63 64 65 |
# File 'lib/axlsx/workbook/worksheet/page_margins.rb', line 63 def @footer end |
#header ⇒ Float
Header margin (in inches)
59 60 61 |
# File 'lib/axlsx/workbook/worksheet/page_margins.rb', line 59 def header @header end |
#left ⇒ Float
Left margin (in inches)
43 44 45 |
# File 'lib/axlsx/workbook/worksheet/page_margins.rb', line 43 def left @left end |
#right ⇒ Float
Right margin (in inches)
47 48 49 |
# File 'lib/axlsx/workbook/worksheet/page_margins.rb', line 47 def right @right end |
#top ⇒ Float
Top margin (in inches)
51 52 53 |
# File 'lib/axlsx/workbook/worksheet/page_margins.rb', line 51 def top @top end |
Instance Method Details
#set(margins) ⇒ Object
Set some or all margins at once.
67 68 69 70 71 72 73 |
# File 'lib/axlsx/workbook/worksheet/page_margins.rb', line 67 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 = '') ⇒ String
For compatibility, this is a noop unless custom margins have been specified.
Serializes the page margins element
93 94 95 |
# File 'lib/axlsx/workbook/worksheet/page_margins.rb', line 93 def to_xml_string(str = '') serialized_tag('pageMargins', str) end |