Class: Writexlsx::PageSetup
- Inherits:
-
Object
- Object
- Writexlsx::PageSetup
- Includes:
- Utility::Common
- Defined in:
- lib/write_xlsx/page_setup.rb
Overview
:nodoc:
Constant Summary
Constants included from Utility::Common
Utility::Common::PERL_TRUE_VALUES
Instance Attribute Summary collapse
-
#across ⇒ Object
writeonly
:nodoc:.
-
#black_white ⇒ Object
:nodoc:.
-
#fit_height ⇒ Object
:nodoc:.
-
#fit_page ⇒ Object
:nodoc:.
-
#fit_width ⇒ Object
:nodoc:.
-
#footer ⇒ Object
Returns the value of attribute footer.
-
#hbreaks ⇒ Object
:nodoc:.
-
#header ⇒ Object
Returns the value of attribute header.
-
#header_footer_aligns ⇒ Object
Returns the value of attribute header_footer_aligns.
-
#header_footer_changed ⇒ Object
Returns the value of attribute header_footer_changed.
-
#header_footer_scales ⇒ Object
Returns the value of attribute header_footer_scales.
-
#horizontal_dpi ⇒ Object
writeonly
Sets the attribute horizontal_dpi.
-
#margin_bottom ⇒ Object
:nodoc:.
-
#margin_footer ⇒ Object
:nodoc:.
-
#margin_header ⇒ Object
:nodoc:.
-
#margin_left ⇒ Object
:nodoc:.
-
#margin_right ⇒ Object
:nodoc:.
-
#margin_top ⇒ Object
:nodoc:.
-
#orientation ⇒ Object
:nodoc:.
-
#page_setup_changed ⇒ Object
:nodoc:.
-
#page_start ⇒ Object
writeonly
Sets the attribute page_start.
-
#print_area ⇒ Object
:nodoc:.
-
#print_options_changed ⇒ Object
:nodoc:.
-
#repeat_cols ⇒ Object
:nodoc:.
-
#repeat_rows ⇒ Object
:nodoc:.
-
#scale ⇒ Object
:nodoc:.
-
#vbreaks ⇒ Object
:nodoc:.
-
#vertical_dpi ⇒ Object
writeonly
Sets the attribute vertical_dpi.
Instance Method Summary collapse
- #center_horizontally ⇒ Object
- #center_vertically ⇒ Object
- #hide_gridlines(option) ⇒ Object
-
#initialize ⇒ PageSetup
constructor
:nodoc:.
- #paper=(paper_size) ⇒ Object
- #print_row_col_headers(headers) ⇒ Object
-
#write_header_footer(writer, excel2003_style) ⇒ Object
Write the
element. -
#write_page_margins(writer) ⇒ Object
Write the
element. -
#write_page_setup(writer) ⇒ Object
Write the
element. -
#write_print_options(writer) ⇒ Object
Write the
element.
Methods included from Utility::Common
#absolute_char, #check_parameter, #float_to_str, #ptrue?, #put_deprecate_message
Constructor Details
#initialize ⇒ PageSetup
:nodoc:
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/write_xlsx/page_setup.rb', line 21 def initialize # :nodoc: @margin_left = 0.7 @margin_right = 0.7 @margin_top = 0.75 @margin_bottom = 0.75 @margin_header = 0.3 @margin_footer = 0.3 @repeat_rows = '' @repeat_cols = '' @print_area = '' @hbreaks = [] @vbreaks = [] @scale = 100 @fit_page = false @fit_width = nil @fit_height = nil @page_setup_changed = false @across = false @orientation = true @header_footer_aligns = true @header_footer_scales = true end |
Instance Attribute Details
#across=(value) ⇒ Object (writeonly)
:nodoc:
15 16 17 |
# File 'lib/write_xlsx/page_setup.rb', line 15 def across=(value) @across = value end |
#black_white ⇒ Object
:nodoc:
16 17 18 |
# File 'lib/write_xlsx/page_setup.rb', line 16 def black_white @black_white end |
#fit_height ⇒ Object
:nodoc:
14 15 16 |
# File 'lib/write_xlsx/page_setup.rb', line 14 def fit_height @fit_height end |
#fit_page ⇒ Object
:nodoc:
14 15 16 |
# File 'lib/write_xlsx/page_setup.rb', line 14 def fit_page @fit_page end |
#fit_width ⇒ Object
:nodoc:
14 15 16 |
# File 'lib/write_xlsx/page_setup.rb', line 14 def fit_width @fit_width end |
#footer ⇒ Object
Returns the value of attribute footer.
17 18 19 |
# File 'lib/write_xlsx/page_setup.rb', line 17 def @footer end |
#hbreaks ⇒ Object
:nodoc:
13 14 15 |
# File 'lib/write_xlsx/page_setup.rb', line 13 def hbreaks @hbreaks end |
#header ⇒ Object
Returns the value of attribute header.
17 18 19 |
# File 'lib/write_xlsx/page_setup.rb', line 17 def header @header end |
#header_footer_aligns ⇒ Object
Returns the value of attribute header_footer_aligns.
17 18 19 |
# File 'lib/write_xlsx/page_setup.rb', line 17 def @header_footer_aligns end |
#header_footer_changed ⇒ Object
Returns the value of attribute header_footer_changed.
17 18 19 |
# File 'lib/write_xlsx/page_setup.rb', line 17 def @header_footer_changed end |
#header_footer_scales ⇒ Object
Returns the value of attribute header_footer_scales.
17 18 19 |
# File 'lib/write_xlsx/page_setup.rb', line 17 def @header_footer_scales end |
#horizontal_dpi=(value) ⇒ Object (writeonly)
Sets the attribute horizontal_dpi
19 20 21 |
# File 'lib/write_xlsx/page_setup.rb', line 19 def horizontal_dpi=(value) @horizontal_dpi = value end |
#margin_bottom ⇒ Object
:nodoc:
10 11 12 |
# File 'lib/write_xlsx/page_setup.rb', line 10 def margin_bottom @margin_bottom end |
#margin_footer ⇒ Object
:nodoc:
11 12 13 |
# File 'lib/write_xlsx/page_setup.rb', line 11 def @margin_footer end |
#margin_header ⇒ Object
:nodoc:
11 12 13 |
# File 'lib/write_xlsx/page_setup.rb', line 11 def margin_header @margin_header end |
#margin_left ⇒ Object
:nodoc:
10 11 12 |
# File 'lib/write_xlsx/page_setup.rb', line 10 def margin_left @margin_left end |
#margin_right ⇒ Object
:nodoc:
10 11 12 |
# File 'lib/write_xlsx/page_setup.rb', line 10 def margin_right @margin_right end |
#margin_top ⇒ Object
:nodoc:
10 11 12 |
# File 'lib/write_xlsx/page_setup.rb', line 10 def margin_top @margin_top end |
#orientation ⇒ Object
:nodoc:
16 17 18 |
# File 'lib/write_xlsx/page_setup.rb', line 16 def orientation @orientation end |
#page_setup_changed ⇒ Object
:nodoc:
14 15 16 |
# File 'lib/write_xlsx/page_setup.rb', line 14 def page_setup_changed @page_setup_changed end |
#page_start=(value) ⇒ Object (writeonly)
Sets the attribute page_start
18 19 20 |
# File 'lib/write_xlsx/page_setup.rb', line 18 def page_start=(value) @page_start = value end |
#print_area ⇒ Object
:nodoc:
12 13 14 |
# File 'lib/write_xlsx/page_setup.rb', line 12 def print_area @print_area end |
#print_options_changed ⇒ Object
:nodoc:
16 17 18 |
# File 'lib/write_xlsx/page_setup.rb', line 16 def @print_options_changed end |
#repeat_cols ⇒ Object
:nodoc:
12 13 14 |
# File 'lib/write_xlsx/page_setup.rb', line 12 def repeat_cols @repeat_cols end |
#repeat_rows ⇒ Object
:nodoc:
12 13 14 |
# File 'lib/write_xlsx/page_setup.rb', line 12 def repeat_rows @repeat_rows end |
#scale ⇒ Object
:nodoc:
13 14 15 |
# File 'lib/write_xlsx/page_setup.rb', line 13 def scale @scale end |
#vbreaks ⇒ Object
:nodoc:
13 14 15 |
# File 'lib/write_xlsx/page_setup.rb', line 13 def vbreaks @vbreaks end |
#vertical_dpi=(value) ⇒ Object (writeonly)
Sets the attribute vertical_dpi
19 20 21 |
# File 'lib/write_xlsx/page_setup.rb', line 19 def vertical_dpi=(value) @vertical_dpi = value end |
Instance Method Details
#center_horizontally ⇒ Object
51 52 53 54 |
# File 'lib/write_xlsx/page_setup.rb', line 51 def center_horizontally @print_options_changed = true @hcenter = true end |
#center_vertically ⇒ Object
56 57 58 59 |
# File 'lib/write_xlsx/page_setup.rb', line 56 def center_vertically @print_options_changed = true @vcenter = true end |
#hide_gridlines(option) ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/write_xlsx/page_setup.rb', line 70 def hide_gridlines(option) if option == 0 || !option @print_gridlines = true @print_options_changed = true else @print_gridlines = false end end |
#paper=(paper_size) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/write_xlsx/page_setup.rb', line 44 def paper=(paper_size) if paper_size @paper_size = paper_size @page_setup_changed = true end end |
#print_row_col_headers(headers) ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/write_xlsx/page_setup.rb', line 61 def print_row_col_headers(headers) if headers @print_headers = true @print_options_changed = true else @print_headers = false end end |
#write_header_footer(writer, excel2003_style) ⇒ Object
Write the
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/write_xlsx/page_setup.rb', line 149 def (writer, excel2003_style) # :nodoc: tag = 'headerFooter' attributes = [] attributes << ['scaleWithDoc', 0] unless ptrue?(@header_footer_scales) attributes << ['alignWithMargins', 0] unless ptrue?(@header_footer_aligns) if @header_footer_changed writer.tag_elements(tag, attributes) do write_odd_header(writer) if @header && @header != '' (writer) if @footer && @footer != '' end elsif excel2003_style writer.empty_tag(tag, attributes) end end |
#write_page_margins(writer) ⇒ Object
Write the
128 129 130 |
# File 'lib/write_xlsx/page_setup.rb', line 128 def write_page_margins(writer) # :nodoc: writer.empty_tag('pageMargins', margin_attributes) end |
#write_page_setup(writer) ⇒ Object
Write the
The following is an example taken from Excel.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/write_xlsx/page_setup.rb', line 99 def write_page_setup(writer) # :nodoc: return unless @page_setup_changed attributes = [] attributes << ['paperSize', @paper_size] if @paper_size attributes << ['scale', @scale] if @scale != 100 attributes << ['fitToWidth', @fit_width] if @fit_page && @fit_width != 1 attributes << ['fitToHeight', @fit_height] if @fit_page && @fit_height != 1 attributes << %w[pageOrder overThenDown] if @across attributes << ['firstPageNumber', @page_start] if @page_start && @page_start > 1 attributes << ['orientation', if @orientation 'portrait' else 'landscape' end] attributes << ['blackAndWhite', 1] if @black_white attributes << ['useFirstPageNumber', 1] if ptrue?(@page_start) # Set the DPI. Mainly only for testing. attributes << ['horizontalDpi', @horizontal_dpi] if @horizontal_dpi attributes << ['verticalDpi', @vertical_dpi] if @vertical_dpi writer.empty_tag('pageSetup', attributes) end |
#write_print_options(writer) ⇒ Object
Write the
135 136 137 138 139 140 141 142 143 144 |
# File 'lib/write_xlsx/page_setup.rb', line 135 def (writer) # :nodoc: return unless @print_options_changed attributes = [] attributes << ['horizontalCentered', 1] if @hcenter attributes << ['verticalCentered', 1] if @vcenter attributes << ['headings', 1] if @print_headers attributes << ['gridLines', 1] if @print_gridlines writer.empty_tag('printOptions', attributes) end |