axlsx 1.1.4 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.yardopts +5 -2
- data/CHANGELOG.md +39 -0
- data/README.md +108 -31
- data/Rakefile +11 -3
- data/examples/basic_charts.rb +54 -0
- data/examples/chart_colors.rb +17 -2
- data/examples/data_validation.rb +50 -0
- data/examples/example.rb +130 -47
- data/examples/example.xlsx +0 -0
- data/examples/example_streamed.xlsx +0 -0
- data/examples/extractive.pdf +0 -0
- data/examples/extractive.rb +3 -0
- data/examples/no-use_autowidth.xlsx +0 -0
- data/examples/scraping_html.rb +91 -0
- data/examples/shared_strings_example.xlsx +0 -0
- data/examples/sheet_protection.rb +10 -0
- data/examples/sheet_view.rb +34 -0
- data/examples/two_cell_anchor_image.rb +11 -0
- data/lib/axlsx/content_type/content_type.rb +2 -0
- data/lib/axlsx/content_type/default.rb +30 -15
- data/lib/axlsx/content_type/override.rb +29 -14
- data/lib/axlsx/doc_props/app.rb +161 -104
- data/lib/axlsx/doc_props/core.rb +9 -5
- data/lib/axlsx/drawing/ax_data_source.rb +7 -6
- data/lib/axlsx/drawing/axis.rb +82 -36
- data/lib/axlsx/drawing/bar_3D_chart.rb +49 -45
- data/lib/axlsx/drawing/bar_series.rb +2 -1
- data/lib/axlsx/drawing/cat_axis.rb +43 -39
- data/lib/axlsx/drawing/chart.rb +65 -54
- data/lib/axlsx/drawing/d_lbls.rb +100 -0
- data/lib/axlsx/drawing/drawing.rb +20 -8
- data/lib/axlsx/drawing/graphic_frame.rb +2 -1
- data/lib/axlsx/drawing/line_3D_chart.rb +3 -10
- data/lib/axlsx/drawing/num_data.rb +2 -2
- data/lib/axlsx/drawing/num_data_source.rb +4 -1
- data/lib/axlsx/drawing/pic.rb +44 -4
- data/lib/axlsx/drawing/pie_3D_chart.rb +10 -7
- data/lib/axlsx/drawing/scatter_chart.rb +2 -8
- data/lib/axlsx/drawing/title.rb +21 -9
- data/lib/axlsx/drawing/two_cell_anchor.rb +46 -9
- data/lib/axlsx/drawing/view_3D.rb +41 -31
- data/lib/axlsx/drawing/vml_drawing.rb +42 -0
- data/lib/axlsx/drawing/vml_shape.rb +125 -0
- data/lib/axlsx/package.rb +44 -16
- data/lib/axlsx/rels/relationship.rb +3 -3
- data/lib/axlsx/rels/relationships.rb +1 -11
- data/lib/axlsx/stylesheet/gradient_fill.rb +1 -1
- data/lib/axlsx/stylesheet/styles.rb +1 -1
- data/lib/axlsx/stylesheet/table_style.rb +3 -3
- data/lib/axlsx/util/constants.rb +28 -0
- data/lib/axlsx/util/simple_typed_list.rb +15 -21
- data/lib/axlsx/util/validators.rb +80 -7
- data/lib/axlsx/version.rb +2 -7
- data/lib/axlsx/workbook/defined_name.rb +174 -0
- data/lib/axlsx/workbook/defined_names.rb +21 -0
- data/lib/axlsx/workbook/workbook.rb +65 -13
- data/lib/axlsx/workbook/worksheet/auto_filter.rb +34 -0
- data/lib/axlsx/workbook/worksheet/cell.rb +35 -7
- data/lib/axlsx/workbook/worksheet/col.rb +15 -0
- data/lib/axlsx/workbook/worksheet/cols.rb +20 -0
- data/lib/axlsx/workbook/worksheet/comment.rb +101 -0
- data/lib/axlsx/workbook/worksheet/comments.rb +85 -0
- data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +25 -0
- data/lib/axlsx/workbook/worksheet/data_bar.rb +1 -1
- data/lib/axlsx/workbook/worksheet/data_validation.rb +245 -0
- data/lib/axlsx/workbook/worksheet/data_validations.rb +28 -0
- data/lib/axlsx/workbook/worksheet/dimension.rb +65 -0
- data/lib/axlsx/workbook/worksheet/merged_cells.rb +35 -0
- data/lib/axlsx/workbook/worksheet/page_setup.rb +113 -0
- data/lib/axlsx/workbook/worksheet/pane.rb +144 -0
- data/lib/axlsx/workbook/worksheet/print_options.rb +63 -0
- data/lib/axlsx/workbook/worksheet/protected_range.rb +46 -0
- data/lib/axlsx/workbook/worksheet/protected_ranges.rb +34 -0
- data/lib/axlsx/workbook/worksheet/row.rb +36 -20
- data/lib/axlsx/workbook/worksheet/selection.rb +111 -0
- data/lib/axlsx/workbook/worksheet/sheet_data.rb +25 -0
- data/lib/axlsx/workbook/worksheet/sheet_pr.rb +24 -0
- data/lib/axlsx/workbook/worksheet/sheet_protection.rb +224 -0
- data/lib/axlsx/workbook/worksheet/sheet_view.rb +379 -0
- data/lib/axlsx/workbook/worksheet/table.rb +2 -2
- data/lib/axlsx/workbook/worksheet/tables.rb +31 -0
- data/lib/axlsx/workbook/worksheet/worksheet.rb +377 -255
- data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +57 -0
- data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +64 -0
- data/lib/axlsx.rb +30 -15
- data/test/content_type/tc_content_type.rb +1 -6
- data/test/doc_props/tc_app.rb +31 -1
- data/test/doc_props/tc_core.rb +3 -1
- data/test/drawing/tc_axis.rb +38 -3
- data/test/drawing/tc_bar_3D_chart.rb +12 -12
- data/test/drawing/tc_bar_series.rb +1 -2
- data/test/drawing/tc_cat_axis.rb +3 -3
- data/test/drawing/tc_chart.rb +29 -9
- data/test/drawing/tc_d_lbls.rb +47 -0
- data/test/drawing/tc_drawing.rb +11 -5
- data/test/drawing/tc_hyperlink.rb +4 -5
- data/test/drawing/tc_line_series.rb +7 -3
- data/test/drawing/tc_num_data.rb +5 -1
- data/test/drawing/tc_pic.rb +22 -2
- data/test/drawing/tc_pie_3D_chart.rb +4 -8
- data/test/drawing/tc_pie_series.rb +7 -2
- data/test/drawing/tc_scatter_chart.rb +6 -1
- data/test/drawing/tc_scatter_series.rb +1 -1
- data/test/drawing/tc_series.rb +1 -1
- data/test/drawing/tc_title.rb +16 -0
- data/test/drawing/tc_two_cell_anchor.rb +1 -2
- data/test/drawing/tc_view_3D.rb +18 -18
- data/test/drawing/tc_vml_drawing.rb +25 -0
- data/test/drawing/tc_vml_shape.rb +100 -0
- data/test/rels/tc_relationship.rb +1 -0
- data/test/stylesheet/tc_gradient_fill.rb +8 -0
- data/test/stylesheet/tc_pattern_fill.rb +7 -1
- data/test/stylesheet/tc_styles.rb +3 -4
- data/test/stylesheet/tc_table_style.rb +8 -0
- data/test/stylesheet/tc_table_style_element.rb +10 -1
- data/test/tc_helper.rb +1 -0
- data/test/tc_package.rb +93 -17
- data/test/util/tc_simple_typed_list.rb +13 -0
- data/test/util/tc_validators.rb +95 -9
- data/test/workbook/tc_defined_name.rb +41 -0
- data/test/workbook/tc_workbook.rb +5 -3
- data/test/workbook/worksheet/table/tc_table.rb +3 -11
- data/test/workbook/worksheet/tc_cell.rb +30 -6
- data/test/workbook/worksheet/tc_col.rb +9 -0
- data/test/workbook/worksheet/tc_comment.rb +57 -0
- data/test/workbook/worksheet/tc_comments.rb +57 -0
- data/test/workbook/worksheet/tc_conditional_formatting.rb +44 -0
- data/test/workbook/worksheet/tc_data_bar.rb +1 -1
- data/test/workbook/worksheet/tc_data_validation.rb +265 -0
- data/test/workbook/worksheet/tc_page_setup.rb +138 -0
- data/test/workbook/worksheet/tc_pane.rb +94 -0
- data/test/workbook/worksheet/tc_print_options.rb +72 -0
- data/test/workbook/worksheet/tc_protected_range.rb +17 -0
- data/test/workbook/worksheet/tc_row.rb +32 -14
- data/test/workbook/worksheet/tc_selection.rb +94 -0
- data/test/workbook/worksheet/tc_sheet_protection.rb +117 -0
- data/test/workbook/worksheet/tc_sheet_view.rb +214 -0
- data/test/workbook/worksheet/tc_worksheet.rb +138 -48
- metadata +140 -80
- data/examples/#extractive.csv# +0 -0
- data/examples/#extractive.rb# +0 -45
- data/examples/chart_colors.rb~ +0 -0
- data/examples/chart_colors.xlsx +0 -0
- data/examples/colored_series_data.xlsx +0 -0
- data/examples/conditional_formatting/getting_barred.xlsx +0 -0
- data/examples/example.csv +0 -1000
- data/examples/extractive.csv +0 -1
- data/examples/extractive.csv~ +0 -1
- data/examples/extractive.rb~ +0 -3
- data/examples/extractive.xlsx +0 -0
- data/examples/stack.rb +0 -21
- data/examples/stack.rb~ +0 -27
- data/examples/stack.xlsx +0 -0
- data/examples/~$chart_colors.xlsx +0 -0
- data/examples/~$extractive.xlsx +0 -0
- data/lib/axlsx/drawing/ax_data_source.rb~ +0 -55
- data/lib/axlsx/drawing/data_source.rb~ +0 -51
- data/lib/axlsx/drawing/hlink_click.rb~ +0 -0
- data/lib/axlsx/drawing/hyperlink.rb~ +0 -64
- data/lib/axlsx/drawing/num_data.rb~ +0 -51
- data/lib/axlsx/drawing/num_data_source.rb~ +0 -54
- data/lib/axlsx/drawing/num_val.rb~ +0 -40
- data/lib/axlsx/drawing/picture_locking.rb~ +0 -36
- data/lib/axlsx/drawing/ref.rb~ +0 -41
- data/lib/axlsx/drawing/str_data.rb~ +0 -58
- data/lib/axlsx/drawing/str_val.rb~ +0 -35
- data/lib/axlsx/util/cbf.rb +0 -333
- data/lib/axlsx/util/cfb.rb~ +0 -201
- data/lib/axlsx/util/font_tables.rb~ +0 -0
- data/lib/axlsx/util/ms_off_crypto.rb +0 -189
- data/lib/axlsx/util/ms_off_crypto.rb~ +0 -3
- data/lib/axlsx/util/ms_offcrypto.rb~ +0 -0
- data/lib/axlsx/util/parser.rb~ +0 -6
- data/lib/axlsx/util/storage.rb~ +0 -0
- data/lib/axlsx/workbook/shared_strings_table.rb~ +0 -69
- data/lib/axlsx/workbook/worksheet/cfvo.rb~ +0 -0
- data/lib/axlsx/workbook/worksheet/col.rb~ +0 -0
- data/lib/axlsx/workbook/worksheet/color_scale.rb~ +0 -46
- data/lib/axlsx/workbook/worksheet/data_bar.rb~ +0 -0
- data/lib/axlsx/workbook/worksheet/icon_set.rb~ +0 -95
- data/lib/axlsx/workbook/worksheet/shared_strings_table.rb~ +0 -0
- data/lib/axlsx/workbook/worksheet/table.rb~ +0 -97
- data/lib/schema/dc.xsd~ +0 -118
- data/lib/schema/dcterms.xsd~ +0 -331
- data/lib/schema/opc-coreProperties.xsd~ +0 -50
- data/test/drawing/tc_data_source.rb~ +0 -30
- data/test/drawing/tc_num_data.rb~ +0 -35
- data/test/drawing/tc_num_val.rb~ +0 -29
- data/test/drawing/tc_str_data.rb~ +0 -30
- data/test/drawing/tc_str_val.rb~ +0 -26
- data/test/workbook/worksheet/table/tc_table.rb~ +0 -72
- data/test/workbook/worksheet/tc_cfvo.rb~ +0 -20
- data/test/workbook/worksheet/tc_col.rb~ +0 -10
- data/test/workbook/worksheet/tc_color_scale.rb~ +0 -0
- data/test/workbook/worksheet/tc_data_bar.rb~ +0 -0
- data/test/workbook/worksheet/tc_icon_set.rb~ +0 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
module Axlsx
|
|
3
|
+
# Data validation allows the validation of cell data
|
|
4
|
+
#
|
|
5
|
+
# @note The recommended way to manage data validations is via Worksheet#add_data_validation
|
|
6
|
+
# @see Worksheet#add_data_validation
|
|
7
|
+
class DataValidation
|
|
8
|
+
|
|
9
|
+
# instance values that must be serialized as their own elements - e.g. not attributes.
|
|
10
|
+
CHILD_ELEMENTS = [:formula1, :formula2]
|
|
11
|
+
|
|
12
|
+
# Formula1
|
|
13
|
+
# Available for type whole, decimal, date, time, textLength, list, custom
|
|
14
|
+
# @see type
|
|
15
|
+
# @return [String]
|
|
16
|
+
# default nil
|
|
17
|
+
attr_reader :formula1
|
|
18
|
+
|
|
19
|
+
# Formula2
|
|
20
|
+
# Available for type whole, decimal, date, time, textLength
|
|
21
|
+
# @see type
|
|
22
|
+
# @return [String]
|
|
23
|
+
# default nil
|
|
24
|
+
attr_reader :formula2
|
|
25
|
+
|
|
26
|
+
# Allow Blank
|
|
27
|
+
# A boolean value indicating whether the data validation allows the use of empty or blank
|
|
28
|
+
# entries. 1 means empty entries are OK and do not violate the validation constraints.
|
|
29
|
+
# Available for type whole, decimal, date, time, textLength, list, custom
|
|
30
|
+
# @see type
|
|
31
|
+
# @return [Boolean]
|
|
32
|
+
# default true
|
|
33
|
+
attr_reader :allowBlank
|
|
34
|
+
|
|
35
|
+
# Error Message
|
|
36
|
+
# Message text of error alert.
|
|
37
|
+
# Available for type whole, decimal, date, time, textLength, list, custom
|
|
38
|
+
# @see type
|
|
39
|
+
# @return [String]
|
|
40
|
+
# default nil
|
|
41
|
+
attr_reader :error
|
|
42
|
+
|
|
43
|
+
# Error Style (ST_DataValidationErrorStyle)
|
|
44
|
+
# The style of error alert used for this data validation.
|
|
45
|
+
# Options are:
|
|
46
|
+
# * information: This data validation error style uses an information icon in the error alert.
|
|
47
|
+
# * stop: This data validation error style uses a stop icon in the error alert.
|
|
48
|
+
# * warning: This data validation error style uses a warning icon in the error alert.
|
|
49
|
+
# Available for type whole, decimal, date, time, textLength, list, custom
|
|
50
|
+
# @see type
|
|
51
|
+
# @return [Symbol]
|
|
52
|
+
# default :stop
|
|
53
|
+
attr_reader :errorStyle
|
|
54
|
+
|
|
55
|
+
# Error Title
|
|
56
|
+
# Title bar text of error alert.
|
|
57
|
+
# Available for type whole, decimal, date, time, textLength, list, custom
|
|
58
|
+
# @see type
|
|
59
|
+
# @return [String]
|
|
60
|
+
# default nil
|
|
61
|
+
attr_reader :errorTitle
|
|
62
|
+
|
|
63
|
+
# Operator (ST_DataValidationOperator)
|
|
64
|
+
# The relational operator used with this data validation.
|
|
65
|
+
# Options are:
|
|
66
|
+
# * between: Data validation which checks if a value is between two other values.
|
|
67
|
+
# * equal: Data validation which checks if a value is equal to a specified value.
|
|
68
|
+
# * greater_than: Data validation which checks if a value is greater than a specified value.
|
|
69
|
+
# * greater_than_or_equal: Data validation which checks if a value is greater than or equal to a specified value.
|
|
70
|
+
# * less_than: Data validation which checks if a value is less than a specified value.
|
|
71
|
+
# * less_than_or_equal: Data validation which checks if a value is less than or equal to a specified value.
|
|
72
|
+
# * not_between: Data validation which checks if a value is not between two other values.
|
|
73
|
+
# * not_equal: Data validation which checks if a value is not equal to a specified value.
|
|
74
|
+
# Available for type whole, decimal, date, time, textLength
|
|
75
|
+
# @see type
|
|
76
|
+
# @return [Symbol]
|
|
77
|
+
# default nil
|
|
78
|
+
attr_reader :operator
|
|
79
|
+
|
|
80
|
+
# Input prompt
|
|
81
|
+
# Message text of input prompt.
|
|
82
|
+
# Available for type whole, decimal, date, time, textLength, list, custom
|
|
83
|
+
# @see type
|
|
84
|
+
# @return [String]
|
|
85
|
+
# default nil
|
|
86
|
+
attr_reader :prompt
|
|
87
|
+
|
|
88
|
+
# Prompt title
|
|
89
|
+
# Title bar text of input prompt.
|
|
90
|
+
# Available for type whole, decimal, date, time, textLength, list, custom
|
|
91
|
+
# @see type
|
|
92
|
+
# @return [String]
|
|
93
|
+
# default nil
|
|
94
|
+
attr_reader :promptTitle
|
|
95
|
+
|
|
96
|
+
# Show drop down
|
|
97
|
+
# A boolean value indicating whether to display a dropdown combo box for a list type data
|
|
98
|
+
# validation. Be careful: false shows the dropdown list!
|
|
99
|
+
# Available for type list
|
|
100
|
+
# @see type
|
|
101
|
+
# @return [Boolean]
|
|
102
|
+
# default false
|
|
103
|
+
attr_reader :showDropDown
|
|
104
|
+
|
|
105
|
+
# Show error message
|
|
106
|
+
# A boolean value indicating whether to display the error alert message when an invalid
|
|
107
|
+
# value has been entered, according to the criteria specified.
|
|
108
|
+
# Available for type whole, decimal, date, time, textLength, list, custom
|
|
109
|
+
# @see type
|
|
110
|
+
# @return [Boolean]
|
|
111
|
+
# default false
|
|
112
|
+
attr_reader :showErrorMessage
|
|
113
|
+
|
|
114
|
+
# Show input message
|
|
115
|
+
# A boolean value indicating whether to display the input prompt message.
|
|
116
|
+
# Available for type whole, decimal, date, time, textLength, list, custom
|
|
117
|
+
# @see type
|
|
118
|
+
# @return [Boolean]
|
|
119
|
+
# default false
|
|
120
|
+
attr_reader :showInputMessage
|
|
121
|
+
|
|
122
|
+
# Range over which data validation is applied, in "A1:B2" format
|
|
123
|
+
# Available for type whole, decimal, date, time, textLength, list, custom
|
|
124
|
+
# @see type
|
|
125
|
+
# @return [String]
|
|
126
|
+
# default nil
|
|
127
|
+
attr_reader :sqref
|
|
128
|
+
|
|
129
|
+
# The type (ST_DataValidationType) of data validation.
|
|
130
|
+
# Options are:
|
|
131
|
+
# * custom: Data validation which uses a custom formula to check the cell value.
|
|
132
|
+
# * date: Data validation which checks for date values satisfying the given condition.
|
|
133
|
+
# * decimal: Data validation which checks for decimal values satisfying the given condition.
|
|
134
|
+
# * list: Data validation which checks for a value matching one of list of values.
|
|
135
|
+
# * none: No data validation.
|
|
136
|
+
# * textLength: Data validation which checks for text values, whose length satisfies the given condition.
|
|
137
|
+
# * time: Data validation which checks for time values satisfying the given condition.
|
|
138
|
+
# * whole: Data validation which checks for whole number values satisfying the given condition.
|
|
139
|
+
# @return [Symbol]
|
|
140
|
+
# default none
|
|
141
|
+
attr_reader :type
|
|
142
|
+
|
|
143
|
+
# Creates a new {DataValidation} object
|
|
144
|
+
# @option options [String] formula1
|
|
145
|
+
# @option options [String] formula2
|
|
146
|
+
# @option options [Boolean] allowBlank - A boolean value indicating whether the data validation allows the use of empty or blank entries.
|
|
147
|
+
# @option options [String] error - Message text of error alert.
|
|
148
|
+
# @option options [Symbol] errorStyle - The style of error alert used for this data validation.
|
|
149
|
+
# @option options [String] errorTitle - itle bar text of error alert.
|
|
150
|
+
# @option options [Symbol] operator - The relational operator used with this data validation.
|
|
151
|
+
# @option options [String] prompt - Message text of input prompt.
|
|
152
|
+
# @option options [String] promptTitle - Title bar text of input prompt.
|
|
153
|
+
# @option options [Boolean] showDropDown - A boolean value indicating whether to display a dropdown combo box for a list type data validation
|
|
154
|
+
# @option options [Boolean] showErrorMessage - A boolean value indicating whether to display the error alert message when an invalid value has been entered, according to the criteria specified.
|
|
155
|
+
# @option options [Boolean] showInputMessage - A boolean value indicating whether to display the input prompt message.
|
|
156
|
+
# @option options [String] sqref - Range over which data validation is applied, in "A1:B2" format.
|
|
157
|
+
# @option options [Symbol] type - The type of data validation.
|
|
158
|
+
def initialize(options={})
|
|
159
|
+
# defaults
|
|
160
|
+
@formula1 = @formula2 = @error = @errorTitle = @operator = @prompt = @promptTitle = @sqref = nil
|
|
161
|
+
@allowBlank = @showErrorMessage = true
|
|
162
|
+
@showDropDown = @showInputMessage = false
|
|
163
|
+
@type = :none
|
|
164
|
+
@errorStyle = :stop
|
|
165
|
+
|
|
166
|
+
options.each do |o|
|
|
167
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# @see formula1
|
|
172
|
+
def formula1=(v); Axlsx::validate_string(v); @formula1 = v end
|
|
173
|
+
|
|
174
|
+
# @see formula2
|
|
175
|
+
def formula2=(v); Axlsx::validate_string(v); @formula2 = v end
|
|
176
|
+
|
|
177
|
+
# @see allowBlank
|
|
178
|
+
def allowBlank=(v); Axlsx::validate_boolean(v); @allowBlank = v end
|
|
179
|
+
|
|
180
|
+
# @see error
|
|
181
|
+
def error=(v); Axlsx::validate_string(v); @error = v end
|
|
182
|
+
|
|
183
|
+
# @see errorStyle
|
|
184
|
+
def errorStyle=(v); Axlsx::validate_data_validation_error_style(v); @errorStyle = v end
|
|
185
|
+
|
|
186
|
+
# @see errorTitle
|
|
187
|
+
def errorTitle=(v); Axlsx::validate_string(v); @errorTitle = v end
|
|
188
|
+
|
|
189
|
+
# @see operator
|
|
190
|
+
def operator=(v); Axlsx::validate_data_validation_operator(v); @operator = v end
|
|
191
|
+
|
|
192
|
+
# @see prompt
|
|
193
|
+
def prompt=(v); Axlsx::validate_string(v); @prompt = v end
|
|
194
|
+
|
|
195
|
+
# @see promptTitle
|
|
196
|
+
def promptTitle=(v); Axlsx::validate_string(v); @promptTitle = v end
|
|
197
|
+
|
|
198
|
+
# @see showDropDown
|
|
199
|
+
def showDropDown=(v); Axlsx::validate_boolean(v); @showDropDown = v end
|
|
200
|
+
|
|
201
|
+
# @see showErrorMessage
|
|
202
|
+
def showErrorMessage=(v); Axlsx::validate_boolean(v); @showErrorMessage = v end
|
|
203
|
+
|
|
204
|
+
# @see showInputMessage
|
|
205
|
+
def showInputMessage=(v); Axlsx::validate_boolean(v); @showInputMessage = v end
|
|
206
|
+
|
|
207
|
+
# @see sqref
|
|
208
|
+
def sqref=(v); Axlsx::validate_string(v); @sqref = v end
|
|
209
|
+
|
|
210
|
+
# @see type
|
|
211
|
+
def type=(v); Axlsx::validate_data_validation_type(v); @type = v end
|
|
212
|
+
|
|
213
|
+
# Serializes the data validation
|
|
214
|
+
# @param [String] str
|
|
215
|
+
# @return [String]
|
|
216
|
+
def to_xml_string(str = '')
|
|
217
|
+
valid_attributes = get_valid_attributes
|
|
218
|
+
|
|
219
|
+
str << '<dataValidation '
|
|
220
|
+
str << instance_values.map { |key, value| '' << key << '="' << value.to_s << '"' if (valid_attributes.include?(key.to_sym) and not CHILD_ELEMENTS.include?(key.to_sym)) }.join(' ')
|
|
221
|
+
str << '>'
|
|
222
|
+
str << '<formula1>' << self.formula1 << '</formula1>' if @formula1 and valid_attributes.include?(:formula1)
|
|
223
|
+
str << '<formula2>' << self.formula2 << '</formula2>' if @formula2 and valid_attributes.include?(:formula2)
|
|
224
|
+
str << '</dataValidation>'
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
private
|
|
228
|
+
def get_valid_attributes
|
|
229
|
+
attributes = [:allowBlank, :error, :errorStyle, :errorTitle, :prompt, :promptTitle, :showErrorMessage, :showInputMessage, :sqref, :type ]
|
|
230
|
+
|
|
231
|
+
if [:whole, :decimal, :data, :time, :textLength].include?(@type)
|
|
232
|
+
attributes << [:operator, :formula1]
|
|
233
|
+
attributes << [:formula2] if [:between, :notBetween].include?(@operator)
|
|
234
|
+
elsif @type == :list
|
|
235
|
+
attributes << [:showDropDown, :formula1]
|
|
236
|
+
elsif @type == :custom
|
|
237
|
+
attributes << [:formula1]
|
|
238
|
+
else
|
|
239
|
+
attributes = []
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
attributes.flatten!
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module Axlsx
|
|
2
|
+
|
|
3
|
+
# A simple, self serializing class for storing conditional formattings
|
|
4
|
+
class DataValidations < SimpleTypedList
|
|
5
|
+
|
|
6
|
+
# creates a new Tables object
|
|
7
|
+
def initialize(worksheet)
|
|
8
|
+
raise ArgumentError, "you must provide a worksheet" unless worksheet.is_a?(Worksheet)
|
|
9
|
+
super DataValidation
|
|
10
|
+
@worksheet = worksheet
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# The worksheet that owns this collection of tables
|
|
14
|
+
# @return [Worksheet]
|
|
15
|
+
attr_reader :worksheet
|
|
16
|
+
|
|
17
|
+
# serialize the conditional formattings
|
|
18
|
+
def to_xml_string(str = "")
|
|
19
|
+
return if empty?
|
|
20
|
+
str << "<dataValidations count='#{size}'>"
|
|
21
|
+
each { |item| item.to_xml_string(str) }
|
|
22
|
+
str << '</dataValidations>'
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
module Axlsx
|
|
2
|
+
|
|
3
|
+
# This class manages the dimensions for a worksheet.
|
|
4
|
+
# While this node is optional in the specification some readers like
|
|
5
|
+
# LibraOffice require this node to render the sheet
|
|
6
|
+
class Dimension
|
|
7
|
+
|
|
8
|
+
# the default value for the first cell in the dimension
|
|
9
|
+
# @return [String]
|
|
10
|
+
def self.default_first
|
|
11
|
+
@@default_first ||= 'A1'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# the default value for the last cell in the dimension
|
|
15
|
+
# @return [String]
|
|
16
|
+
def self.default_last
|
|
17
|
+
@@default_last ||= 'AA200'
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# Creates a new dimension object
|
|
22
|
+
# @param[Worksheet] worksheet - the worksheet this dimension applies
|
|
23
|
+
# to.
|
|
24
|
+
def initialize(worksheet)
|
|
25
|
+
raise ArgumentError, "you must provide a worksheet" unless worksheet.is_a?(Worksheet)
|
|
26
|
+
@worksheet = worksheet
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
attr_reader :worksheet
|
|
30
|
+
|
|
31
|
+
# the full refernece for this dimension
|
|
32
|
+
# @return [String]
|
|
33
|
+
def sqref
|
|
34
|
+
"#{first_cell_reference}:#{last_cell_reference}"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# serialize the object
|
|
38
|
+
# @return [String]
|
|
39
|
+
def to_xml_string(str = '')
|
|
40
|
+
return if worksheet.rows.empty?
|
|
41
|
+
str << "<dimension ref=\"%s\"></dimension>" % sqref
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# The first cell in the dimension
|
|
45
|
+
# @return [String]
|
|
46
|
+
def first_cell_reference
|
|
47
|
+
dimension_reference(worksheet.rows.first.cells.first, Dimension.default_first)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# the last cell in the dimension
|
|
51
|
+
# @return [String]
|
|
52
|
+
def last_cell_reference
|
|
53
|
+
dimension_reference(worksheet.rows.last.cells.last, Dimension.default_last)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
private
|
|
57
|
+
|
|
58
|
+
# Returns the reference of a cell or the default specified
|
|
59
|
+
# @return [String]
|
|
60
|
+
def dimension_reference(cell, default)
|
|
61
|
+
return default unless cell.respond_to?(:r)
|
|
62
|
+
cell.r
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module Axlsx
|
|
2
|
+
|
|
3
|
+
# A simple list of merged cells
|
|
4
|
+
class MergedCells < SimpleTypedList
|
|
5
|
+
|
|
6
|
+
# creates a new MergedCells object
|
|
7
|
+
# @param [Worksheet] worksheet
|
|
8
|
+
def initialize(worksheet)
|
|
9
|
+
raise ArgumentError, 'you must provide a worksheet' unless worksheet.is_a?(Worksheet)
|
|
10
|
+
super String
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# adds cells to the merged cells collection
|
|
14
|
+
# @param [Array||String] cells The cells to add to the merged cells
|
|
15
|
+
# collection. This can be an array of actual cells or a string style
|
|
16
|
+
# range like 'A1:C1'
|
|
17
|
+
def add(cells)
|
|
18
|
+
@list << if cells.is_a?(String)
|
|
19
|
+
cells
|
|
20
|
+
elsif cells.is_a?(Array)
|
|
21
|
+
Axlsx::cell_range(cells, false)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# serialize the object
|
|
26
|
+
# @param [String] str
|
|
27
|
+
# @return [String]
|
|
28
|
+
def to_xml_string(str = '')
|
|
29
|
+
return if @list.empty?
|
|
30
|
+
str << "<mergeCells count='#{size}'>"
|
|
31
|
+
each { |merged_cell| str << "<mergeCell ref='#{merged_cell}'></mergeCell>" }
|
|
32
|
+
str << '</mergeCells>'
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
module Axlsx
|
|
2
|
+
# Page setup settings for printing a worksheet. All settings are optional.
|
|
3
|
+
#
|
|
4
|
+
# @note The recommended way to manage print options is via Worksheet#page_setup
|
|
5
|
+
# @see Worksheet#print_options
|
|
6
|
+
# @see Worksheet#initialize
|
|
7
|
+
class PageSetup
|
|
8
|
+
|
|
9
|
+
# TODO: Attributes defined by Open XML spec that are not implemented yet:
|
|
10
|
+
#
|
|
11
|
+
# * blackAndWhite
|
|
12
|
+
# * cellComments
|
|
13
|
+
# * copies
|
|
14
|
+
# * draft
|
|
15
|
+
# * errors
|
|
16
|
+
# * firstPageNumber
|
|
17
|
+
# * horizontalDpi
|
|
18
|
+
# * pageOrder
|
|
19
|
+
# * paperSize
|
|
20
|
+
# * useFirstPageNumber
|
|
21
|
+
# * usePrinterDefaults
|
|
22
|
+
# * verticalDpi
|
|
23
|
+
|
|
24
|
+
# Number of vertical pages to fit on.
|
|
25
|
+
# @note PageSetup#fit_to is the recomended way to manage page fitting as only specifying one of fit_to_width/fit_to_height will result in the counterpart
|
|
26
|
+
# being set to 1.
|
|
27
|
+
# @return [Integer]
|
|
28
|
+
attr_reader :fit_to_height
|
|
29
|
+
|
|
30
|
+
# Number of horizontal pages to fit on.
|
|
31
|
+
# @note PageSetup#fit_to is the recomended way to manage page fitting as only specifying one of width/height will result in the counterpart
|
|
32
|
+
# being set to 1.
|
|
33
|
+
# @return [Integer]
|
|
34
|
+
attr_reader :fit_to_width
|
|
35
|
+
|
|
36
|
+
# Orientation of the page (:default, :landscape, :portrait)
|
|
37
|
+
# @return [Symbol]
|
|
38
|
+
attr_reader :orientation
|
|
39
|
+
|
|
40
|
+
# Height of paper (string containing a number followed by a unit identifier: "297mm", "11in")
|
|
41
|
+
# @return [String]
|
|
42
|
+
attr_reader :paper_height
|
|
43
|
+
|
|
44
|
+
# Width of paper (string containing a number followed by a unit identifier: "210mm", "8.5in")
|
|
45
|
+
# @return [String]
|
|
46
|
+
attr_reader :paper_width
|
|
47
|
+
|
|
48
|
+
# Print scaling (percent value, given as integer ranging from 10 to 400)
|
|
49
|
+
# @return [Integer]
|
|
50
|
+
attr_reader :scale
|
|
51
|
+
|
|
52
|
+
# Creates a new PageSetup object
|
|
53
|
+
# @option options [Integer] fit_to_height Number of vertical pages to fit on
|
|
54
|
+
# @option options [Integer] fit_to_width Number of horizontal pages to fit on
|
|
55
|
+
# @option options [Symbol] orientation Orientation of the page (:default, :landscape, :portrait)
|
|
56
|
+
# @option options [String] paper_height Height of paper (number followed by unit identifier: "297mm", "11in")
|
|
57
|
+
# @option options [String] paper_width Width of paper (number followed by unit identifier: "210mm", "8.5in")
|
|
58
|
+
# @option options [Integer] scale Print scaling (percent value, integer ranging from 10 to 400)
|
|
59
|
+
def initialize(options = {})
|
|
60
|
+
set(options)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Set some or all page settings at once.
|
|
64
|
+
# @param [Hash] options The page settings to set (possible keys are :fit_to_height, :fit_to_width, :orientation, :paper_height, :paper_width, and :scale).
|
|
65
|
+
def set(options)
|
|
66
|
+
options.each do |k, v|
|
|
67
|
+
send("#{k}=", v) if respond_to? "#{k}="
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# @see fit_to_height
|
|
72
|
+
def fit_to_height=(v); Axlsx::validate_unsigned_int(v); @fit_to_height = v; end
|
|
73
|
+
# @see fit_to_width
|
|
74
|
+
def fit_to_width=(v); Axlsx::validate_unsigned_int(v); @fit_to_width = v; end
|
|
75
|
+
# @see orientation
|
|
76
|
+
def orientation=(v); Axlsx::validate_page_orientation(v); @orientation = v; end
|
|
77
|
+
# @see paper_height
|
|
78
|
+
def paper_height=(v); Axlsx::validate_number_with_unit(v); @paper_height = v; end
|
|
79
|
+
# @see paper_width
|
|
80
|
+
def paper_width=(v); Axlsx::validate_number_with_unit(v); @paper_width = v; end
|
|
81
|
+
# @see scale
|
|
82
|
+
def scale=(v); Axlsx::validate_scale_10_400(v); @scale = v; end
|
|
83
|
+
|
|
84
|
+
# convenience method to achieve sanity when setting fit_to_width and fit_to_height
|
|
85
|
+
# as they both default to 1 if only their counterpart is specified.
|
|
86
|
+
# @note This method will overwrite any value you explicitly set via the fit_to_height or fit_to_width methods.
|
|
87
|
+
# @option options [Integer] width The number of pages to fit this worksheet on horizontally. Default 9999
|
|
88
|
+
# @option options [Integer] height The number of pages to fit this worksheet on vertically. Default 9999
|
|
89
|
+
def fit_to(options={})
|
|
90
|
+
self.fit_to_width = options[:width] || 9999
|
|
91
|
+
self.fit_to_height = options[:height] || 9999
|
|
92
|
+
[@fit_to_width, @fit_to_height]
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
# helper method for worksheet to determine if the page setup is configured for fit to page printing
|
|
97
|
+
# We treat any page set up that has a value set for fit_to_width or fit_to_height value as fit_to_page.
|
|
98
|
+
# @return [Boolean]
|
|
99
|
+
def fit_to_page?
|
|
100
|
+
# is there some better what to express this?
|
|
101
|
+
(fit_to_width != nil || fit_to_height != nil)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# Serializes the page settings element.
|
|
105
|
+
# @param [String] str
|
|
106
|
+
# @return [String]
|
|
107
|
+
def to_xml_string(str = '')
|
|
108
|
+
str << '<pageSetup '
|
|
109
|
+
str << instance_values.reject{ |k, v| k == 'worksheet' }.map{ |k,v| k.gsub(/_(.)/){ $1.upcase } << %{="#{v}"} }.join(' ')
|
|
110
|
+
str << '/>'
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
module Axlsx
|
|
3
|
+
# Pane options for a worksheet.
|
|
4
|
+
#
|
|
5
|
+
# @note The recommended way to manage the pane options is via SheetView#pane
|
|
6
|
+
# @see SheetView#pane
|
|
7
|
+
class Pane
|
|
8
|
+
|
|
9
|
+
# Active Pane
|
|
10
|
+
# The pane that is active.
|
|
11
|
+
# Options are
|
|
12
|
+
# * bottom_left: Bottom left pane, when both vertical and horizontal
|
|
13
|
+
# splits are applied. This value is also used when only
|
|
14
|
+
# a horizontal split has been applied, dividing the pane
|
|
15
|
+
# into upper and lower regions. In that case, this value
|
|
16
|
+
# specifies the bottom pane.
|
|
17
|
+
# * bottom_right: Bottom right pane, when both vertical and horizontal
|
|
18
|
+
# splits are applied.
|
|
19
|
+
# * top_left: Top left pane, when both vertical and horizontal splits
|
|
20
|
+
# are applied. This value is also used when only a horizontal
|
|
21
|
+
# split has been applied, dividing the pane into upper and lower
|
|
22
|
+
# regions. In that case, this value specifies the top pane.
|
|
23
|
+
# This value is also used when only a vertical split has
|
|
24
|
+
# been applied, dividing the pane into right and left
|
|
25
|
+
# regions. In that case, this value specifies the left pane
|
|
26
|
+
# * top_right: Top right pane, when both vertical and horizontal
|
|
27
|
+
# splits are applied. This value is also used when only
|
|
28
|
+
# a vertical split has been applied, dividing the pane
|
|
29
|
+
# into right and left regions. In that case, this value
|
|
30
|
+
# specifies the right pane.
|
|
31
|
+
# @see type
|
|
32
|
+
# @return [Symbol]
|
|
33
|
+
# default nil
|
|
34
|
+
attr_reader :active_pane
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
# Split State
|
|
38
|
+
# Indicates whether the pane has horizontal / vertical
|
|
39
|
+
# splits, and whether those splits are frozen.
|
|
40
|
+
# Options are
|
|
41
|
+
# * frozen: Panes are frozen, but were not split being frozen. In
|
|
42
|
+
# this state, when the panes are unfrozen again, a single
|
|
43
|
+
# pane results, with no split. In this state, the split
|
|
44
|
+
# bars are not adjustable.
|
|
45
|
+
# * frozen_split: Panes are frozen and were split before being frozen. In
|
|
46
|
+
# this state, when the panes are unfrozen again, the split
|
|
47
|
+
# remains, but is adjustable.
|
|
48
|
+
# * split: Panes are split, but not frozen. In this state, the split
|
|
49
|
+
# bars are adjustable by the user.
|
|
50
|
+
# @see type
|
|
51
|
+
# @return [Symbol]
|
|
52
|
+
# default nil
|
|
53
|
+
attr_reader :state
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
# Top Left Visible Cell
|
|
57
|
+
# Location of the top left visible cell in the bottom
|
|
58
|
+
# right pane (when in Left-To-Right mode).
|
|
59
|
+
# @see type
|
|
60
|
+
# @return [String]
|
|
61
|
+
# default nil
|
|
62
|
+
attr_reader :top_left_cell
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
# Horizontal Split Position
|
|
66
|
+
# Horizontal position of the split, in 1/20th of a point; 0 (zero)
|
|
67
|
+
# if none. If the pane is frozen, this value indicates the number
|
|
68
|
+
# of columns visible in the top pane.
|
|
69
|
+
# @see type
|
|
70
|
+
# @return [Integer]
|
|
71
|
+
# default 0
|
|
72
|
+
attr_reader :x_split
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
# Vertical Split Position
|
|
76
|
+
# Vertical position of the split, in 1/20th of a point; 0 (zero)
|
|
77
|
+
# if none. If the pane is frozen, this value indicates the number
|
|
78
|
+
# of rows visible in the left pane.
|
|
79
|
+
# @see type
|
|
80
|
+
# @return [Integer]
|
|
81
|
+
# default 0
|
|
82
|
+
attr_reader :y_split
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
# Creates a new {Pane} object
|
|
86
|
+
# @option options [Symbol] active_pane Active Pane
|
|
87
|
+
# @option options [Symbol] state Split State
|
|
88
|
+
# @option options [Cell, String] top_left_cell Top Left Visible Cell
|
|
89
|
+
# @option options [Integer] x_split Horizontal Split Position
|
|
90
|
+
# @option options [Integer] y_split Vertical Split Position
|
|
91
|
+
def initialize(options={})
|
|
92
|
+
#defaults
|
|
93
|
+
@active_pane = @state = @top_left_cell = nil
|
|
94
|
+
@x_split = @y_split = 0
|
|
95
|
+
|
|
96
|
+
# write options to instance variables
|
|
97
|
+
options.each do |o|
|
|
98
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
# @see active_pane
|
|
104
|
+
def active_pane=(v); Axlsx::validate_pane_type(v); @active_pane = v end
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
# @see state
|
|
108
|
+
def state=(v); Axlsx::validate_split_state_type(v); @state = v end
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
# @see top_left_cell
|
|
112
|
+
def top_left_cell=(v)
|
|
113
|
+
cell = (v.class == Axlsx::Cell ? v.r_abs : v)
|
|
114
|
+
Axlsx::validate_string(cell)
|
|
115
|
+
@top_left_cell = cell
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
# @see x_split
|
|
120
|
+
def x_split=(v); Axlsx::validate_unsigned_int(v); @x_split = v end
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
# @see y_split
|
|
124
|
+
def y_split=(v); Axlsx::validate_unsigned_int(v); @y_split = v end
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
# Serializes the data validation
|
|
128
|
+
# @param [String] str
|
|
129
|
+
# @return [String]
|
|
130
|
+
def to_xml_string(str = '')
|
|
131
|
+
if @state == :frozen && @top_left_cell.nil?
|
|
132
|
+
row = @y_split || 0
|
|
133
|
+
column = @x_split || 0
|
|
134
|
+
|
|
135
|
+
@top_left_cell = "#{('A'..'ZZ').to_a[column]}#{row+1}"
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
str << '<pane '
|
|
139
|
+
str << instance_values.map { |key, value| '' << key.gsub(/_(.)/){ $1.upcase } <<
|
|
140
|
+
%{="#{[:active_pane, :state].include?(key.to_sym) ? value.to_s.gsub(/_(.)/){ $1.upcase } : value}"} unless value.nil? }.join(' ')
|
|
141
|
+
str << '/>'
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
module Axlsx
|
|
2
|
+
# Options for printing a worksheet. All options are boolean and false by default.
|
|
3
|
+
#
|
|
4
|
+
# @note The recommended way to manage print options is via Worksheet#print_options
|
|
5
|
+
# @see Worksheet#print_options
|
|
6
|
+
# @see Worksheet#initialize
|
|
7
|
+
class PrintOptions
|
|
8
|
+
|
|
9
|
+
# Whether grid lines should be printed.
|
|
10
|
+
# @return [Boolean]
|
|
11
|
+
attr_reader :grid_lines
|
|
12
|
+
|
|
13
|
+
# Whether row and column headings should be printed.
|
|
14
|
+
# @return [Boolean]
|
|
15
|
+
attr_reader :headings
|
|
16
|
+
|
|
17
|
+
# Whether the content should be centered horizontally on the page.
|
|
18
|
+
# @return [Boolean]
|
|
19
|
+
attr_reader :horizontal_centered
|
|
20
|
+
|
|
21
|
+
# Whether the content should be centered vertically on the page.
|
|
22
|
+
# @return [Boolean]
|
|
23
|
+
attr_reader :vertical_centered
|
|
24
|
+
|
|
25
|
+
# Creates a new PrintOptions object
|
|
26
|
+
# @option options [Boolean] grid_lines Whether grid lines should be printed
|
|
27
|
+
# @option options [Boolean] headings Whether row and column headings should be printed
|
|
28
|
+
# @option options [Boolean] horizontal_centered Whether the content should be centered horizontally
|
|
29
|
+
# @option options [Boolean] vertical_centered Whether the content should be centered vertically
|
|
30
|
+
def initialize(options = {})
|
|
31
|
+
@grid_lines = @headings = @horizontal_centered = @vertical_centered = false
|
|
32
|
+
set(options)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Set some or all options at once.
|
|
36
|
+
# @param [Hash] options The options to set (possible keys are :grid_lines, :headings, :horizontal_centered, and :vertical_centered).
|
|
37
|
+
def set(options)
|
|
38
|
+
options.each do |k, v|
|
|
39
|
+
send("#{k}=", v) if respond_to? "#{k}="
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# @see grid_lines
|
|
44
|
+
def grid_lines=(v); Axlsx::validate_boolean(v); @grid_lines = v; end
|
|
45
|
+
# @see headings
|
|
46
|
+
def headings=(v); Axlsx::validate_boolean(v); @headings = v; end
|
|
47
|
+
# @see horizontal_centered
|
|
48
|
+
def horizontal_centered=(v); Axlsx::validate_boolean(v); @horizontal_centered = v; end
|
|
49
|
+
# @see vertical_centered
|
|
50
|
+
def vertical_centered=(v); Axlsx::validate_boolean(v); @vertical_centered = v; end
|
|
51
|
+
|
|
52
|
+
# Serializes the page options element.
|
|
53
|
+
# @note As all attributes default to "false" according to the xml schema definition, the generated xml includes only those attributes that are set to true.
|
|
54
|
+
# @param [String] str
|
|
55
|
+
# @return [String]
|
|
56
|
+
def to_xml_string(str = '')
|
|
57
|
+
str << '<printOptions '
|
|
58
|
+
#
|
|
59
|
+
str << instance_values.select{ |k,v| v == true }.map{ |k,v| k.gsub(/_(.)/){ $1.upcase } << %{="#{v}"} }.join(' ')
|
|
60
|
+
str << '/>'
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|