Class: Writexlsx::Worksheet::PageSetup
- Inherits:
-
Object
- Object
- Writexlsx::Worksheet::PageSetup
- Includes:
- Utility
- Defined in:
- lib/write_xlsx/worksheet/page_setup.rb
Overview
:nodoc:
Constant Summary
Constants included from Utility
Utility::CHAR_WIDTHS, Utility::COL_MAX, Utility::PERL_TRUE_VALUES, Utility::ROW_MAX, Utility::SHEETNAME_MAX, Utility::STR_MAX
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 <headerFooter> element.
-
#write_page_margins(writer) ⇒ Object
Write the <pageMargins> element.
-
#write_page_setup(writer) ⇒ Object
Write the <pageSetup> element.
-
#write_print_options(writer) ⇒ Object
Write the <printOptions> element.
Methods included from Utility
#absolute_char, #check_dimensions, #check_dimensions_and_update_max_min_values, #check_parameter, #color, #convert_date_time, #convert_font_args, #dash_types, delete_files, #escape_url, #fill_properties, #float_to_str, #get_font_latin_attributes, #get_font_style_attributes, #get_image_properties, #layout_properties, #legend_properties, #line_fill_properties, #line_properties, #palette_color, #params_to_font, #pattern_properties, #pixels_to_points, #process_bmp, #process_gif, #process_jpg, #process_png, #process_workbook_options, #ptrue?, #put_deprecate_message, #quote_sheetname, #r_id_attributes, #row_col_notation, #shape_style_base, #store_col_max_min_values, #store_row_max_min_values, #substitute_cellref, #underline_attributes, #v_shape_attributes_base, #v_shape_style_base, #value_or_raise, #write_a_body_pr, #write_a_def_rpr, #write_a_end_para_rpr, #write_a_lst_style, #write_a_p_formula, #write_a_p_pr_formula, #write_a_solid_fill, #write_a_srgb_clr, #write_anchor, #write_auto_fill, #write_color, #write_comment_path, #write_def_rpr_r_pr_common, #write_div, #write_fill, #write_font, #write_stroke, #write_tx_pr, #write_xml_declaration, #xl_cell_to_rowcol, #xl_col_to_name, #xl_range, #xl_range_formula, #xl_rowcol_to_cell, #xl_string_pixel_width, #xml_str
Constructor Details
#initialize ⇒ PageSetup
:nodoc:
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 20 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:
14 15 16 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 14 def across=(value) @across = value end |
#black_white ⇒ Object
:nodoc:
15 16 17 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 15 def black_white @black_white end |
#fit_height ⇒ Object
:nodoc:
13 14 15 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 13 def fit_height @fit_height end |
#fit_page ⇒ Object
:nodoc:
13 14 15 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 13 def fit_page @fit_page end |
#fit_width ⇒ Object
:nodoc:
13 14 15 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 13 def fit_width @fit_width end |
#footer ⇒ Object
Returns the value of attribute footer.
16 17 18 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 16 def @footer end |
#hbreaks ⇒ Object
:nodoc:
12 13 14 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 12 def hbreaks @hbreaks end |
#header ⇒ Object
Returns the value of attribute header.
16 17 18 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 16 def header @header end |
#header_footer_aligns ⇒ Object
Returns the value of attribute header_footer_aligns.
16 17 18 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 16 def @header_footer_aligns end |
#header_footer_changed ⇒ Object
Returns the value of attribute header_footer_changed.
16 17 18 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 16 def @header_footer_changed end |
#header_footer_scales ⇒ Object
Returns the value of attribute header_footer_scales.
16 17 18 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 16 def @header_footer_scales end |
#horizontal_dpi=(value) ⇒ Object (writeonly)
Sets the attribute horizontal_dpi
18 19 20 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 18 def horizontal_dpi=(value) @horizontal_dpi = value end |
#margin_bottom ⇒ Object
:nodoc:
9 10 11 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 9 def margin_bottom @margin_bottom end |
#margin_footer ⇒ Object
:nodoc:
10 11 12 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 10 def @margin_footer end |
#margin_header ⇒ Object
:nodoc:
10 11 12 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 10 def margin_header @margin_header end |
#margin_left ⇒ Object
:nodoc:
9 10 11 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 9 def margin_left @margin_left end |
#margin_right ⇒ Object
:nodoc:
9 10 11 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 9 def margin_right @margin_right end |
#margin_top ⇒ Object
:nodoc:
9 10 11 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 9 def margin_top @margin_top end |
#orientation ⇒ Object
:nodoc:
15 16 17 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 15 def orientation @orientation end |
#page_setup_changed ⇒ Object
:nodoc:
13 14 15 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 13 def page_setup_changed @page_setup_changed end |
#page_start=(value) ⇒ Object (writeonly)
Sets the attribute page_start
17 18 19 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 17 def page_start=(value) @page_start = value end |
#print_area ⇒ Object
:nodoc:
11 12 13 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 11 def print_area @print_area end |
#print_options_changed ⇒ Object
:nodoc:
15 16 17 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 15 def @print_options_changed end |
#repeat_cols ⇒ Object
:nodoc:
11 12 13 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 11 def repeat_cols @repeat_cols end |
#repeat_rows ⇒ Object
:nodoc:
11 12 13 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 11 def repeat_rows @repeat_rows end |
#scale ⇒ Object
:nodoc:
12 13 14 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 12 def scale @scale end |
#vbreaks ⇒ Object
:nodoc:
12 13 14 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 12 def vbreaks @vbreaks end |
#vertical_dpi=(value) ⇒ Object (writeonly)
Sets the attribute vertical_dpi
18 19 20 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 18 def vertical_dpi=(value) @vertical_dpi = value end |
Instance Method Details
#center_horizontally ⇒ Object
50 51 52 53 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 50 def center_horizontally @print_options_changed = true @hcenter = true end |
#center_vertically ⇒ Object
55 56 57 58 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 55 def center_vertically @print_options_changed = true @vcenter = true end |
#hide_gridlines(option) ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 69 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
43 44 45 46 47 48 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 43 def paper=(paper_size) if paper_size @paper_size = paper_size @page_setup_changed = true end end |
#print_row_col_headers(headers) ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 60 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 <headerFooter> element.
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 148 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 <pageMargins> element.
127 128 129 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 127 def write_page_margins(writer) # :nodoc: writer.empty_tag('pageMargins', margin_attributes) end |
#write_page_setup(writer) ⇒ Object
Write the <pageSetup> element.
The following is an example taken from Excel.
<pageSetup
paperSize="9"
scale="110"
fitToWidth="2"
fitToHeight="2"
pageOrder="overThenDown"
orientation="portrait"
useFirstPageNumber="1"
blackAndWhite="1"
draft="1"
horizontalDpi="200"
verticalDpi="200"
r:id="rId1"
/>
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 98 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 <printOptions> element.
134 135 136 137 138 139 140 141 142 143 |
# File 'lib/write_xlsx/worksheet/page_setup.rb', line 134 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 |