Class: Axlsx::PageSetup
- Inherits:
-
Object
- Object
- Axlsx::PageSetup
- Defined in:
- lib/axlsx/workbook/worksheet/page_setup.rb
Overview
The recommended way to manage print options is via Worksheet#page_setup
Page setup settings for printing a worksheet. All settings are optional.
Instance Attribute Summary collapse
- #fit_to_height ⇒ Integer
-
#fit_to_width ⇒ Integer
Number of horizontal pages to fit on.
-
#orientation ⇒ Symbol
Orientation of the page (:default, :landscape, :portrait).
-
#paper_height ⇒ String
Height of paper (string containing a number followed by a unit identifier: "297mm", "11in").
-
#paper_width ⇒ String
Width of paper (string containing a number followed by a unit identifier: "210mm", "8.5in").
-
#scale ⇒ Integer
Print scaling (percent value, given as integer ranging from 10 to 400).
Instance Method Summary collapse
-
#fit_to(options = {}) ⇒ Object
convenience method to achieve sanity when setting fit_to_width and fit_to_height as they both default to 1 if only their counterpart is specified.
-
#fit_to_page? ⇒ Boolean
helper method for worksheet to determine if the page setup is configured for fit to page printing We treat any page set up that has a value set for fit_to_width or fit_to_height value as fit_to_page.
-
#initialize(options = {}) ⇒ PageSetup
constructor
Creates a new PageSetup object.
-
#set(options) ⇒ Object
Set some or all page settings at once.
-
#to_xml_string(str = '') ⇒ String
Serializes the page settings element.
Constructor Details
#initialize(options = {}) ⇒ PageSetup
Creates a new PageSetup object
59 60 61 |
# File 'lib/axlsx/workbook/worksheet/page_setup.rb', line 59 def initialize( = {}) set() end |
Instance Attribute Details
#fit_to_height ⇒ Integer
28 29 30 |
# File 'lib/axlsx/workbook/worksheet/page_setup.rb', line 28 def fit_to_height @fit_to_height end |
#fit_to_width ⇒ Integer
PageSetup#fit_to is the recomended way to manage page fitting as only specifying one of width/height will result in the counterpart
Number of horizontal pages to fit on. being set to 1.
34 35 36 |
# File 'lib/axlsx/workbook/worksheet/page_setup.rb', line 34 def fit_to_width @fit_to_width end |
#orientation ⇒ Symbol
Orientation of the page (:default, :landscape, :portrait)
38 39 40 |
# File 'lib/axlsx/workbook/worksheet/page_setup.rb', line 38 def orientation @orientation end |
#paper_height ⇒ String
Height of paper (string containing a number followed by a unit identifier: "297mm", "11in")
42 43 44 |
# File 'lib/axlsx/workbook/worksheet/page_setup.rb', line 42 def paper_height @paper_height end |
#paper_width ⇒ String
Width of paper (string containing a number followed by a unit identifier: "210mm", "8.5in")
46 47 48 |
# File 'lib/axlsx/workbook/worksheet/page_setup.rb', line 46 def paper_width @paper_width end |
#scale ⇒ Integer
Print scaling (percent value, given as integer ranging from 10 to 400)
50 51 52 |
# File 'lib/axlsx/workbook/worksheet/page_setup.rb', line 50 def scale @scale end |
Instance Method Details
#fit_to(options = {}) ⇒ Object
This method will overwrite any value you explicitly set via the fit_to_height or fit_to_width methods.
convenience method to achieve sanity when setting fit_to_width and fit_to_height as they both default to 1 if only their counterpart is specified.
89 90 91 92 93 |
# File 'lib/axlsx/workbook/worksheet/page_setup.rb', line 89 def fit_to(={}) self.fit_to_width = [:width] || 9999 self.fit_to_height = [:height] || 9999 [@fit_to_width, @fit_to_height] end |
#fit_to_page? ⇒ Boolean
helper method for worksheet to determine if the page setup is configured for fit to page printing We treat any page set up that has a value set for fit_to_width or fit_to_height value as fit_to_page.
99 100 101 102 |
# File 'lib/axlsx/workbook/worksheet/page_setup.rb', line 99 def fit_to_page? # is there some better what to express this? (fit_to_width != nil || fit_to_height != nil) end |
#set(options) ⇒ Object
Set some or all page settings at once.
65 66 67 68 69 |
# File 'lib/axlsx/workbook/worksheet/page_setup.rb', line 65 def set() .each do |k, v| send("#{k}=", v) if respond_to? "#{k}=" end end |
#to_xml_string(str = '') ⇒ String
Serializes the page settings element.
107 108 109 110 111 |
# File 'lib/axlsx/workbook/worksheet/page_setup.rb', line 107 def to_xml_string(str = '') str << '<pageSetup ' str << instance_values.reject{ |k, v| k == 'worksheet' }.map{ |k,v| k.gsub(/_(.)/){ $1.upcase } << %{="#{v}"} }.join(' ') str << '/>' end |