xlsxrb 0.1.17 → 0.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +256 -1
- data/README.md +111 -28
- data/lib/ruby_lsp/xlsxrb/completion_listener.rb +439 -139
- data/lib/xlsxrb/chart_builder.rb +540 -193
- data/lib/xlsxrb/dsl_helpers.rb +178 -73
- data/lib/xlsxrb/elements/cell.rb +197 -130
- data/lib/xlsxrb/elements/column.rb +88 -7
- data/lib/xlsxrb/elements/coordinate_access.rb +86 -59
- data/lib/xlsxrb/elements/image.rb +18 -19
- data/lib/xlsxrb/elements/metadata.rb +2379 -0
- data/lib/xlsxrb/elements/row.rb +84 -118
- data/lib/xlsxrb/elements/styles.rb +140 -90
- data/lib/xlsxrb/elements/types.rb +164 -22
- data/lib/xlsxrb/elements/workbook.rb +122 -140
- data/lib/xlsxrb/elements/worksheet.rb +451 -226
- data/lib/xlsxrb/elements.rb +1 -0
- data/lib/xlsxrb/ooxml/reader/listeners/core_listeners.rb +16 -5
- data/lib/xlsxrb/ooxml/reader/listeners/drawing_listeners.rb +14 -9
- data/lib/xlsxrb/ooxml/reader/listeners/feature_listeners.rb +296 -34
- data/lib/xlsxrb/ooxml/reader/listeners/style_listeners.rb +17 -3
- data/lib/xlsxrb/ooxml/reader.rb +52 -50
- data/lib/xlsxrb/ooxml/styles_parser.rb +36 -5
- data/lib/xlsxrb/ooxml/utils.rb +2 -2
- data/lib/xlsxrb/ooxml/workbook_parser.rb +0 -1
- data/lib/xlsxrb/ooxml/workbook_writer.rb +242 -109
- data/lib/xlsxrb/ooxml/worksheet_parser.rb +63 -31
- data/lib/xlsxrb/ooxml/worksheet_writer.rb +119 -56
- data/lib/xlsxrb/ooxml/writer/drawing_xml.rb +33 -13
- data/lib/xlsxrb/ooxml/writer/features_xml.rb +75 -15
- data/lib/xlsxrb/ooxml/writer/styles_xml.rb +18 -8
- data/lib/xlsxrb/ooxml/writer.rb +124 -44
- data/lib/xlsxrb/ooxml/xml_parser.rb +78 -5
- data/lib/xlsxrb/ooxml/zip_generator.rb +2 -0
- data/lib/xlsxrb/ooxml/zip_reader.rb +112 -25
- data/lib/xlsxrb/ooxml/zip_writer.rb +119 -30
- data/lib/xlsxrb/stream_row.rb +56 -81
- data/lib/xlsxrb/stream_sheet.rb +542 -273
- data/lib/xlsxrb/stream_writer.rb +1536 -870
- data/lib/xlsxrb/style_builder.rb +667 -221
- data/lib/xlsxrb/version.rb +1 -1
- data/lib/xlsxrb/workbook_builder.rb +406 -143
- data/lib/xlsxrb/worksheet_builder.rb +1009 -900
- data/lib/xlsxrb.rb +1179 -1056
- data/sig/generated/xlsxrb/chart_builder.rbs +385 -159
- data/sig/generated/xlsxrb/dsl_helpers.rbs +81 -15
- data/sig/generated/xlsxrb/elements/cell.rbs +78 -70
- data/sig/generated/xlsxrb/elements/column.rbs +55 -3
- data/sig/generated/xlsxrb/elements/coordinate_access.rbs +35 -29
- data/sig/generated/xlsxrb/elements/image.rbs +7 -11
- data/sig/generated/xlsxrb/elements/metadata.rbs +1574 -0
- data/sig/generated/xlsxrb/elements/row.rbs +39 -42
- data/sig/generated/xlsxrb/elements/styles.rbs +66 -66
- data/sig/generated/xlsxrb/elements/types.rbs +27 -0
- data/sig/generated/xlsxrb/elements/workbook.rbs +46 -99
- data/sig/generated/xlsxrb/elements/worksheet.rbs +121 -96
- data/sig/generated/xlsxrb/ooxml/reader/listeners/feature_listeners.rbs +61 -4
- data/sig/generated/xlsxrb/ooxml/reader.rbs +2 -2
- data/sig/generated/xlsxrb/ooxml/styles_parser.rbs +1 -1
- data/sig/generated/xlsxrb/ooxml/utils.rbs +3 -3
- data/sig/generated/xlsxrb/ooxml/workbook_writer.rbs +13 -1
- data/sig/generated/xlsxrb/ooxml/worksheet_parser.rbs +16 -0
- data/sig/generated/xlsxrb/ooxml/worksheet_writer.rbs +6 -4
- data/sig/generated/xlsxrb/ooxml/writer/features_xml.rbs +7 -0
- data/sig/generated/xlsxrb/ooxml/writer.rbs +22 -13
- data/sig/generated/xlsxrb/ooxml/xml_parser.rbs +70 -0
- data/sig/generated/xlsxrb/ooxml/zip_generator.rbs +2 -0
- data/sig/generated/xlsxrb/ooxml/zip_reader.rbs +24 -9
- data/sig/generated/xlsxrb/ooxml/zip_writer.rbs +26 -1
- data/sig/generated/xlsxrb/stream_row.rbs +32 -33
- data/sig/generated/xlsxrb/stream_sheet.rbs +233 -181
- data/sig/generated/xlsxrb/stream_writer.rbs +961 -667
- data/sig/generated/xlsxrb/style_builder.rbs +402 -128
- data/sig/generated/xlsxrb/workbook_builder.rbs +223 -71
- data/sig/generated/xlsxrb/worksheet_builder.rbs +579 -453
- data/sig/generated/xlsxrb.rbs +205 -144
- data/sig/rexml.rbs +8 -0
- metadata +5 -5
- data/lib/xlsxrb/utils.rb +0 -291
- data/sig/generated/xlsxrb/utils.rbs +0 -184
|
@@ -64,7 +64,11 @@ module Xlsxrb
|
|
|
64
64
|
@pending_row_attributes = {}
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
#: String
|
|
68
|
+
attr_reader :name
|
|
69
|
+
|
|
70
|
+
#: Array[Hash[Symbol, untyped]]
|
|
71
|
+
attr_reader :defined_names
|
|
68
72
|
|
|
69
73
|
# Defines or configures a named cell style.
|
|
70
74
|
#
|
|
@@ -87,27 +91,62 @@ module Xlsxrb
|
|
|
87
91
|
style_builder
|
|
88
92
|
end
|
|
89
93
|
|
|
94
|
+
# Creates an {Elements::Formula} object.
|
|
95
|
+
# @api public
|
|
96
|
+
#: (String expression, ?cached_value: (String | Numeric | bool | Elements::CellError | nil), ?type: (Symbol | String)?, ?ref: String?, ?shared_index: Integer?) -> Elements::Formula
|
|
97
|
+
def formula(...)
|
|
98
|
+
Xlsxrb.formula(...)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Creates an array or dynamic array {Elements::Formula} object.
|
|
102
|
+
# @api public
|
|
103
|
+
#: (String expression, ?ref: String?, ?cached_value: (String | Numeric | bool | Elements::CellError | nil), **untyped attrs) -> Elements::Formula
|
|
104
|
+
def array_formula(...)
|
|
105
|
+
Xlsxrb.array_formula(...)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# Creates a shared formula {Elements::Formula} object.
|
|
109
|
+
# @api public
|
|
110
|
+
#: (?String? expression, ?shared_index: Integer?, ?ref: String?, ?cached_value: (String | Numeric | bool | Elements::CellError | nil)) -> Elements::Formula
|
|
111
|
+
def shared_formula(...)
|
|
112
|
+
Xlsxrb.shared_formula(...)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# Creates an {Elements::RichText} object.
|
|
116
|
+
# @api public
|
|
117
|
+
#: (*(Hash[Symbol, untyped] | Elements::RichTextRun | String | Array[untyped] | untyped) runs, ?text: String?, ?base_font: untyped, **untyped font_props) -> Elements::RichText
|
|
118
|
+
def rich_text(...)
|
|
119
|
+
Xlsxrb.rich_text(...)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Creates or returns an {Elements::CellError} object.
|
|
123
|
+
# @api public
|
|
124
|
+
#: (String | Symbol | Elements::CellError code) -> Elements::CellError
|
|
125
|
+
def cell_error(...)
|
|
126
|
+
Xlsxrb.cell_error(...)
|
|
127
|
+
end
|
|
128
|
+
|
|
90
129
|
# Appends a row of cells to the worksheet.
|
|
91
130
|
#
|
|
92
131
|
# @example Add a row with values and array styles
|
|
93
|
-
# sheet.row(["ID", "Name", "Total"],
|
|
132
|
+
# sheet.row(["ID", "Name", "Total"], cell_styles: [:header, :header, :header])
|
|
94
133
|
#
|
|
95
134
|
# @example Add a row with a hash of column keys
|
|
96
135
|
# sheet.row({ "A" => "Invoice", "C" => 12345 })
|
|
97
136
|
#
|
|
98
137
|
# @param values [Array<Object>, Hash{String, Integer => Object}] The cell values.
|
|
99
|
-
# @param
|
|
138
|
+
# @param cell_styles [String, Symbol, Array<String | Symbol>, Hash, nil] Style names or inline styles to apply to each cell.
|
|
139
|
+
# @param row_style [Integer, Symbol, String, Hash, nil] Row style format or index.
|
|
100
140
|
# @param height [Float, Integer, nil] The row height in points (0 to 409).
|
|
101
141
|
# @param hidden [Boolean] Whether the row is hidden.
|
|
102
142
|
# @param custom_height [Boolean] Whether custom row height is enforced.
|
|
103
143
|
# @param outline_level [Integer, nil] Grouping/outline hierarchy level.
|
|
104
144
|
# @param collapsed [Boolean] Whether the row is collapsed.
|
|
105
|
-
# @param style [Integer, Symbol, String, Hash, nil] Row style format or index.
|
|
106
145
|
# @return [void]
|
|
107
146
|
# @raise [ArgumentError] If limits are exceeded when strict_excel_mode is enabled.
|
|
108
147
|
# @api public
|
|
109
|
-
#: (Array[untyped] | Hash[untyped, untyped] values, ?
|
|
110
|
-
def row(values,
|
|
148
|
+
#: (Array[untyped] | Hash[untyped, untyped] values, ?cell_styles: untyped, ?row_style: (Integer | Symbol | String | Hash[Symbol, untyped])?, ?height: Float | Integer | nil, ?hidden: bool, ?custom_height: bool, ?collapsed: bool, ?outline_level: Integer | nil) -> void
|
|
149
|
+
def row(values, cell_styles: nil, row_style: nil, height: nil, hidden: false, custom_height: false, collapsed: false, outline_level: nil)
|
|
111
150
|
row_index = @next_row_index
|
|
112
151
|
DslHelpers.validate_row_bounds!(row_index, height, strict_excel_mode: @strict_excel_mode)
|
|
113
152
|
@next_row_index += 1
|
|
@@ -119,32 +158,32 @@ module Xlsxrb
|
|
|
119
158
|
height ||= pending[:height]
|
|
120
159
|
|
|
121
160
|
values = DslHelpers.normalize_row_values(values)
|
|
122
|
-
|
|
161
|
+
cell_styles = DslHelpers.normalize_row_styles(cell_styles)
|
|
123
162
|
|
|
124
163
|
# Auto-detect Date / Time for built-in styles
|
|
125
164
|
values.each_with_index do |val, idx|
|
|
126
|
-
cell_style =
|
|
165
|
+
cell_style = cell_styles.is_a?(Array) ? cell_styles[idx] : cell_styles
|
|
127
166
|
|
|
128
|
-
if val.is_a?(Date) && cell_style.nil?
|
|
167
|
+
if val.is_a?(Date) && !val.is_a?(DateTime) && cell_style.nil?
|
|
129
168
|
style("__xlsxrb_date", number_format: "yyyy-mm-dd") unless @styles.key?("__xlsxrb_date")
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
elsif val.is_a?(Time) && cell_style.nil?
|
|
169
|
+
cell_styles = [] if cell_styles.nil?
|
|
170
|
+
cell_styles = Array.new(values.size, cell_styles) unless cell_styles.is_a?(Array)
|
|
171
|
+
cell_styles[idx] = "__xlsxrb_date"
|
|
172
|
+
elsif (val.is_a?(Time) || val.is_a?(DateTime)) && cell_style.nil?
|
|
134
173
|
style("__xlsxrb_time", number_format: "yyyy-mm-dd hh:mm:ss") unless @styles.key?("__xlsxrb_time")
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
174
|
+
cell_styles = [] if cell_styles.nil?
|
|
175
|
+
cell_styles = Array.new(values.size, cell_styles) unless cell_styles.is_a?(Array)
|
|
176
|
+
cell_styles[idx] = "__xlsxrb_time"
|
|
138
177
|
end
|
|
139
178
|
end
|
|
140
179
|
|
|
141
180
|
max_len = values.size
|
|
142
|
-
max_len = [max_len,
|
|
181
|
+
max_len = [max_len, cell_styles.size].max if cell_styles.is_a?(Array)
|
|
143
182
|
# See: https://support.microsoft.com/en-us/office/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3
|
|
144
183
|
raise ArgumentError, "Row contains #{max_len} columns, exceeding Excel limit of 16_384 columns" if @strict_excel_mode && max_len > 16_384
|
|
145
184
|
|
|
146
185
|
cells = Array.new(max_len)
|
|
147
|
-
style_lookup =
|
|
186
|
+
style_lookup = cell_styles.is_a?(Array)
|
|
148
187
|
|
|
149
188
|
col_index = 0
|
|
150
189
|
while col_index < max_len
|
|
@@ -164,9 +203,9 @@ module Xlsxrb
|
|
|
164
203
|
end
|
|
165
204
|
|
|
166
205
|
style_name = if style_lookup
|
|
167
|
-
col_index <
|
|
206
|
+
col_index < cell_styles.size ? cell_styles[col_index] : nil
|
|
168
207
|
else
|
|
169
|
-
|
|
208
|
+
cell_styles
|
|
170
209
|
end
|
|
171
210
|
|
|
172
211
|
if style_name.is_a?(Hash)
|
|
@@ -179,8 +218,8 @@ module Xlsxrb
|
|
|
179
218
|
next
|
|
180
219
|
end
|
|
181
220
|
sb = @styles[style_name]
|
|
182
|
-
fmt_code = if sb&.
|
|
183
|
-
sb.
|
|
221
|
+
fmt_code = if sb&.number_format
|
|
222
|
+
sb.number_format.is_a?(String) ? sb.number_format : Ooxml::Utils::BUILTIN_NUM_FMT_CODES[sb.number_format]
|
|
184
223
|
end
|
|
185
224
|
# If value is a Formula object or Hash with :formula, store it as the cell's formula
|
|
186
225
|
cells[col_index] = if val.is_a?(Elements::Formula)
|
|
@@ -189,20 +228,20 @@ module Xlsxrb
|
|
|
189
228
|
column_index: col_index,
|
|
190
229
|
value: val.cached_value,
|
|
191
230
|
formula: val,
|
|
192
|
-
|
|
231
|
+
style: style_name,
|
|
193
232
|
raw_value: val.cached_value&.to_s,
|
|
194
233
|
format_code: fmt_code
|
|
195
234
|
)
|
|
196
|
-
elsif val.is_a?(Hash) && (val.key?(:formula) || val.key?(:expression) || (val[:type]&.to_sym == :shared &&
|
|
235
|
+
elsif val.is_a?(Hash) && (val.key?(:formula) || val.key?(:expression) || (val[:type]&.to_sym == :shared && val.key?(:shared_index)))
|
|
197
236
|
cached_val = val.key?(:value) ? val[:value] : val[:cached_value]
|
|
198
237
|
f_expr = val[:formula] || val[:expression] || ""
|
|
199
|
-
f_type = val[:type] || (:shared if val.key?(:shared_index)
|
|
238
|
+
f_type = val[:type] || (:shared if val.key?(:shared_index))
|
|
200
239
|
f_obj = Elements::Formula.new(
|
|
201
240
|
expression: f_expr,
|
|
202
241
|
cached_value: cached_val,
|
|
203
242
|
type: f_type,
|
|
204
243
|
ref: val[:ref],
|
|
205
|
-
shared_index: val[:shared_index]
|
|
244
|
+
shared_index: val[:shared_index],
|
|
206
245
|
calculate_always: val[:calculate_always]
|
|
207
246
|
)
|
|
208
247
|
Elements::Cell.new(
|
|
@@ -210,7 +249,7 @@ module Xlsxrb
|
|
|
210
249
|
column_index: col_index,
|
|
211
250
|
value: cached_val,
|
|
212
251
|
formula: f_obj,
|
|
213
|
-
|
|
252
|
+
style: style_name,
|
|
214
253
|
raw_value: cached_val&.to_s,
|
|
215
254
|
format_code: fmt_code
|
|
216
255
|
)
|
|
@@ -219,7 +258,7 @@ module Xlsxrb
|
|
|
219
258
|
row_index: row_index,
|
|
220
259
|
column_index: col_index,
|
|
221
260
|
value: val,
|
|
222
|
-
|
|
261
|
+
style: style_name,
|
|
223
262
|
raw_value: val&.to_s,
|
|
224
263
|
format_code: fmt_code
|
|
225
264
|
)
|
|
@@ -228,7 +267,7 @@ module Xlsxrb
|
|
|
228
267
|
end
|
|
229
268
|
|
|
230
269
|
cells.compact!
|
|
231
|
-
unmapped =
|
|
270
|
+
unmapped = Elements::EMPTY_HASH
|
|
232
271
|
@rows << Elements::Row.new(
|
|
233
272
|
index: row_index,
|
|
234
273
|
cells: cells,
|
|
@@ -237,10 +276,10 @@ module Xlsxrb
|
|
|
237
276
|
custom_height: custom_height || !height.nil?,
|
|
238
277
|
collapsed: collapsed,
|
|
239
278
|
outline_level: outline_level,
|
|
279
|
+
style_index: row_style,
|
|
240
280
|
unmapped_data: unmapped
|
|
241
281
|
)
|
|
242
282
|
end
|
|
243
|
-
alias add_row row
|
|
244
283
|
|
|
245
284
|
# Appends a row to the worksheet and returns self for chaining.
|
|
246
285
|
#
|
|
@@ -258,9 +297,6 @@ module Xlsxrb
|
|
|
258
297
|
|
|
259
298
|
# Advances the row cursor by count without writing empty row elements.
|
|
260
299
|
#
|
|
261
|
-
# @example Skip one row
|
|
262
|
-
# sheet.skip_row
|
|
263
|
-
#
|
|
264
300
|
# @example Skip multiple rows
|
|
265
301
|
# sheet.skip_rows(3)
|
|
266
302
|
#
|
|
@@ -273,7 +309,6 @@ module Xlsxrb
|
|
|
273
309
|
|
|
274
310
|
@next_row_index += count
|
|
275
311
|
end
|
|
276
|
-
alias skip_row skip_rows
|
|
277
312
|
|
|
278
313
|
# Sets column formatting and properties for one or multiple columns.
|
|
279
314
|
#
|
|
@@ -290,8 +325,8 @@ module Xlsxrb
|
|
|
290
325
|
# @return [void]
|
|
291
326
|
# @raise [ArgumentError] If width exceeds 255 in strict mode.
|
|
292
327
|
# @api public
|
|
293
|
-
#: (Integer | String | Range[Integer | String] | Array[Integer | String] index, ?width: Float | Integer | nil, ?hidden: bool, ?custom_width: bool, ?outline_level: Integer | nil, ?collapsed: bool, ?style: (Integer | Symbol | String | Hash[Symbol, untyped])?) -> void
|
|
294
|
-
def column(index, width: nil, hidden: false, custom_width: false, outline_level: nil, collapsed: false, style: nil)
|
|
328
|
+
#: (Integer | String | Symbol | Range[Integer | String | Symbol] | Array[Integer | String | Symbol] index, ?width: Float | Integer | nil, ?hidden: bool, ?custom_width: bool, ?outline_level: Integer | nil, ?collapsed: bool, ?style: (Integer | Symbol | String | Hash[Symbol, untyped])?, ?best_fit: bool) -> void
|
|
329
|
+
def column(index, width: nil, hidden: false, custom_width: false, outline_level: nil, collapsed: false, style: nil, best_fit: false)
|
|
295
330
|
raise ArgumentError, "Column width #{width} must be between 0 and 255 characters (Excel limitation)" if @strict_excel_mode && width && (width.negative? || width > 255)
|
|
296
331
|
|
|
297
332
|
DslHelpers.normalize_column_indices(index).each do |idx|
|
|
@@ -299,13 +334,14 @@ module Xlsxrb
|
|
|
299
334
|
if existing_idx
|
|
300
335
|
prev = @columns[existing_idx]
|
|
301
336
|
new_width = width.nil? ? prev.width : width
|
|
302
|
-
new_custom_width = (custom_width || !width.nil?) || prev.custom_width
|
|
303
|
-
new_hidden = hidden || prev.hidden
|
|
337
|
+
new_custom_width = (custom_width || !width.nil?) || prev.custom_width?
|
|
338
|
+
new_hidden = hidden || prev.hidden?
|
|
304
339
|
new_outline = outline_level.nil? ? prev.outline_level : outline_level
|
|
305
340
|
new_style = style.nil? ? prev.style_index : style
|
|
306
341
|
unmapped = prev.unmapped_data ? prev.unmapped_data.dup : {}
|
|
307
342
|
unmapped[:style_index] = new_style if new_style
|
|
308
343
|
unmapped[:collapsed] = true if collapsed || prev.unmapped_data&.[](:collapsed)
|
|
344
|
+
unmapped[:best_fit] = true if best_fit || prev.unmapped_data&.[](:best_fit)
|
|
309
345
|
@columns[existing_idx] = Elements::Column.new(
|
|
310
346
|
index: idx,
|
|
311
347
|
width: new_width,
|
|
@@ -318,6 +354,7 @@ module Xlsxrb
|
|
|
318
354
|
else
|
|
319
355
|
unmapped = style ? { style_index: style } : {}
|
|
320
356
|
unmapped[:collapsed] = true if collapsed
|
|
357
|
+
unmapped[:best_fit] = true if best_fit
|
|
321
358
|
@columns << Elements::Column.new(
|
|
322
359
|
index: idx,
|
|
323
360
|
width: width,
|
|
@@ -330,6 +367,16 @@ module Xlsxrb
|
|
|
330
367
|
end
|
|
331
368
|
end
|
|
332
369
|
@columns.sort_by!(&:index)
|
|
370
|
+
nil
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
# Returns column configurations defined for this worksheet.
|
|
374
|
+
#
|
|
375
|
+
# @return [Array<Elements::Column>]
|
|
376
|
+
# @api public
|
|
377
|
+
#: () -> Array[Elements::Column]
|
|
378
|
+
def columns
|
|
379
|
+
@columns.map { |c| c.is_a?(Elements::Column) ? c : Elements::Column.new(**c) }
|
|
333
380
|
end
|
|
334
381
|
|
|
335
382
|
# Groups multiple columns together with outline hierarchy.
|
|
@@ -352,9 +399,6 @@ module Xlsxrb
|
|
|
352
399
|
def group_columns(index, level: 1, collapsed: false, hidden: false, width: nil, style: nil)
|
|
353
400
|
column(index, outline_level: level, collapsed: collapsed, hidden: hidden, width: width, style: style)
|
|
354
401
|
end
|
|
355
|
-
alias group_column group_columns
|
|
356
|
-
alias group_cols group_columns
|
|
357
|
-
alias group_col group_columns
|
|
358
402
|
|
|
359
403
|
# Groups multiple rows with outline hierarchy, either by range or with a block.
|
|
360
404
|
#
|
|
@@ -404,10 +448,11 @@ module Xlsxrb
|
|
|
404
448
|
index: existing_row.index,
|
|
405
449
|
cells: existing_row.cells,
|
|
406
450
|
height: existing_row.height,
|
|
407
|
-
hidden: hidden || existing_row.hidden
|
|
408
|
-
custom_height: existing_row.custom_height
|
|
409
|
-
collapsed: collapsed || existing_row.collapsed
|
|
451
|
+
hidden: hidden || existing_row.hidden?,
|
|
452
|
+
custom_height: existing_row.custom_height?,
|
|
453
|
+
collapsed: collapsed || existing_row.collapsed?,
|
|
410
454
|
outline_level: level,
|
|
455
|
+
style_index: existing_row.style_index,
|
|
411
456
|
unmapped_data: existing_row.unmapped_data
|
|
412
457
|
)
|
|
413
458
|
else
|
|
@@ -416,9 +461,11 @@ module Xlsxrb
|
|
|
416
461
|
end
|
|
417
462
|
end
|
|
418
463
|
end
|
|
419
|
-
alias group_row group_rows
|
|
420
464
|
|
|
421
|
-
# Configures worksheet-level outline and grouping view properties.
|
|
465
|
+
# Configures or queries worksheet-level outline and grouping view properties.
|
|
466
|
+
#
|
|
467
|
+
# When called with no arguments, returns the outline properties Hash.
|
|
468
|
+
# When called with arguments, updates outline properties and returns nil.
|
|
422
469
|
#
|
|
423
470
|
# @example Show summary row below detail rows
|
|
424
471
|
# sheet.outline_properties(summary_below: true, summary_right: true)
|
|
@@ -426,42 +473,58 @@ module Xlsxrb
|
|
|
426
473
|
# @param summary_below [Boolean, nil] Flag indicating if summary rows appear below detail rows.
|
|
427
474
|
# @param summary_right [Boolean, nil] Flag indicating if summary columns appear to the right of detail columns.
|
|
428
475
|
# @param show_outline_symbols [Boolean, nil] Flag indicating whether outline symbols are visible.
|
|
429
|
-
# @param show_symbols [Boolean, nil] Alias for show_outline_symbols.
|
|
430
476
|
# @param apply_styles [Boolean, nil] Flag indicating whether automatic styles apply to outlines.
|
|
431
477
|
# @param opts [Hash] Additional options.
|
|
432
|
-
# @return [Hash]
|
|
478
|
+
# @return [Hash<Symbol, untyped>, void]
|
|
433
479
|
# @api public
|
|
434
|
-
#: (
|
|
435
|
-
|
|
480
|
+
#: () -> Hash[Symbol, untyped]
|
|
481
|
+
#: (?summary_below: bool?, ?summary_right: bool?, ?show_outline_symbols: bool?, ?apply_styles: bool?, **untyped opts) -> void
|
|
482
|
+
def outline_properties(summary_below: nil, summary_right: nil, show_outline_symbols: nil, apply_styles: nil, **opts)
|
|
483
|
+
return @sheet_properties.slice(:summary_below, :summary_right, :show_outline_symbols, :apply_styles) if summary_below.nil? && summary_right.nil? && show_outline_symbols.nil? && apply_styles.nil? && opts.empty?
|
|
484
|
+
|
|
436
485
|
props = (@sheet_properties[:outline_properties] || {}).dup
|
|
437
486
|
props[:summary_below] = summary_below unless summary_below.nil?
|
|
438
487
|
props[:summary_right] = summary_right unless summary_right.nil?
|
|
439
|
-
|
|
440
|
-
props[:show_outline_symbols] = symbols unless symbols.nil?
|
|
488
|
+
props[:show_outline_symbols] = show_outline_symbols unless show_outline_symbols.nil?
|
|
441
489
|
props[:apply_styles] = apply_styles unless apply_styles.nil?
|
|
442
490
|
props.merge!(opts)
|
|
443
491
|
@sheet_properties[:outline_properties] = props
|
|
444
492
|
@sheet_properties[:summary_below] = props[:summary_below] unless props[:summary_below].nil?
|
|
445
493
|
@sheet_properties[:summary_right] = props[:summary_right] unless props[:summary_right].nil?
|
|
446
|
-
|
|
494
|
+
nil
|
|
495
|
+
end
|
|
496
|
+
|
|
497
|
+
# Sets worksheet outline and grouping view properties.
|
|
498
|
+
#
|
|
499
|
+
# @param opts [Hash] Outline properties.
|
|
500
|
+
# @return [void]
|
|
501
|
+
# @api public
|
|
502
|
+
#: (Hash[Symbol, untyped] opts) -> void
|
|
503
|
+
def outline_properties=(opts)
|
|
504
|
+
h = opts.respond_to?(:to_h) ? opts.to_h : (opts || {})
|
|
505
|
+
outline_properties(**h)
|
|
506
|
+
nil
|
|
447
507
|
end
|
|
448
|
-
alias outline_pr outline_properties
|
|
449
508
|
|
|
450
509
|
# Adds a chart to the worksheet.
|
|
451
510
|
#
|
|
511
|
+
# @param type [Symbol, String, nil] Optional chart type (e.g. :bar, :line).
|
|
452
512
|
# @param options [Hash] Chart configuration options.
|
|
453
513
|
# @yield [builder]
|
|
454
514
|
# @yieldparam builder [Xlsxrb::ChartBuilder]
|
|
455
515
|
# @return [void]
|
|
456
516
|
# @api public
|
|
457
|
-
#: (**untyped options) ?{ (ChartBuilder) -> void } -> void
|
|
458
|
-
def chart(**options)
|
|
517
|
+
#: (?Symbol | String? type, **untyped options) ?{ (ChartBuilder) -> void } -> void
|
|
518
|
+
def chart(type = nil, **options)
|
|
519
|
+
options = options.merge(type: type) if type
|
|
459
520
|
if block_given?
|
|
460
521
|
builder = ChartBuilder.new
|
|
522
|
+
builder.type = type if type
|
|
461
523
|
yield builder
|
|
462
524
|
options = builder.options.merge(options)
|
|
463
525
|
end
|
|
464
526
|
@charts << options
|
|
527
|
+
nil
|
|
465
528
|
end
|
|
466
529
|
|
|
467
530
|
# Adds a hyperlink to a cell.
|
|
@@ -492,48 +555,81 @@ module Xlsxrb
|
|
|
492
555
|
@hyperlinks << link
|
|
493
556
|
end
|
|
494
557
|
|
|
495
|
-
#
|
|
558
|
+
# Returns the auto-filter range for the worksheet, or nil if none.
|
|
496
559
|
#
|
|
497
|
-
# @
|
|
498
|
-
# @return [String]
|
|
560
|
+
# @return [String, nil]
|
|
499
561
|
# @api public
|
|
500
|
-
#: (
|
|
501
|
-
|
|
502
|
-
|
|
562
|
+
#: () -> String?
|
|
563
|
+
attr_reader :auto_filter
|
|
564
|
+
|
|
565
|
+
# Sets the auto-filter range for the worksheet.
|
|
566
|
+
#
|
|
567
|
+
# @param range [String, nil] Cell range (e.g. "A1:E100").
|
|
568
|
+
# @return [String, nil]
|
|
569
|
+
# @api public
|
|
570
|
+
#: (String? range) -> String?
|
|
571
|
+
def auto_filter=(range)
|
|
572
|
+
@auto_filter = range&.to_s
|
|
503
573
|
end
|
|
504
574
|
|
|
505
575
|
# Configures filtering rules on a specific column of an auto-filter.
|
|
506
576
|
#
|
|
507
|
-
# @param col_id [Integer] 0-based column index relative to filter range.
|
|
577
|
+
# @param col_id [Integer, String, Symbol] 0-based column index relative to filter range or column letter ("A", :B).
|
|
508
578
|
# @param filter [Hash] Filter criteria (e.g. values, custom filters).
|
|
509
|
-
# @return [
|
|
579
|
+
# @return [void]
|
|
510
580
|
# @api public
|
|
511
|
-
#: (Integer col_id, Hash[untyped, untyped] filter) ->
|
|
581
|
+
#: (Integer | String | Symbol col_id, (Hash[untyped, untyped] | Array[untyped]) filter) -> void
|
|
512
582
|
def filter_column(col_id, filter)
|
|
583
|
+
col_id = Elements::Cell._column_index(col_id) if col_id.is_a?(String) || col_id.is_a?(Symbol)
|
|
513
584
|
@filter_columns[col_id] = filter
|
|
585
|
+
nil
|
|
514
586
|
end
|
|
515
587
|
|
|
516
|
-
# Configures column sort state for the sheet.
|
|
588
|
+
# Configures or queries column sort state for the sheet.
|
|
589
|
+
#
|
|
590
|
+
# When called with no arguments, returns the {Elements::SortState} value object.
|
|
591
|
+
# When called with arguments, updates sort state and returns nil.
|
|
517
592
|
#
|
|
518
|
-
# @param ref [String] The sorted range.
|
|
519
|
-
# @param sort_conditions [Array<Hash
|
|
593
|
+
# @param ref [String, nil] The sorted range.
|
|
594
|
+
# @param sort_conditions [Array<Hash>, nil] List of sort condition definitions.
|
|
595
|
+
# @param case_sensitive [Boolean] Whether sorting is case sensitive.
|
|
596
|
+
# @param sort_method [String, nil] Sort method.
|
|
520
597
|
# @param opts [Hash] Additional sort state options.
|
|
521
|
-
# @return [
|
|
598
|
+
# @return [Elements::SortState, nil, void]
|
|
522
599
|
# @api public
|
|
523
|
-
#: (
|
|
524
|
-
|
|
525
|
-
|
|
600
|
+
#: () -> Elements::SortState?
|
|
601
|
+
#: (?String? ref, ?Array[Hash[untyped, untyped]]? sort_conditions, ?case_sensitive: bool, ?sort_method: String?, **untyped opts) -> void
|
|
602
|
+
def sort_state(ref = nil, sort_conditions = nil, case_sensitive: false, sort_method: nil, **opts)
|
|
603
|
+
if ref.nil? && sort_conditions.nil?
|
|
604
|
+
return @sort_state ? Elements::SortState.new(**@sort_state) : nil
|
|
605
|
+
end
|
|
606
|
+
|
|
607
|
+
entry = { ref: ref, sort_conditions: sort_conditions, case_sensitive: case_sensitive }
|
|
608
|
+
entry[:sort_method] = sort_method if sort_method
|
|
609
|
+
@sort_state = entry.merge(opts)
|
|
610
|
+
nil
|
|
611
|
+
end
|
|
612
|
+
|
|
613
|
+
# Sets column sort state for the sheet.
|
|
614
|
+
#
|
|
615
|
+
# @param opts [Elements::SortState, Hash, nil] Sort state options.
|
|
616
|
+
# @return [void]
|
|
617
|
+
# @api public
|
|
618
|
+
#: (Elements::SortState | Hash[Symbol, untyped] | nil opts) -> void
|
|
619
|
+
def sort_state=(opts)
|
|
620
|
+
@sort_state = opts&.respond_to?(:to_h) ? opts.to_h : opts
|
|
621
|
+
nil
|
|
526
622
|
end
|
|
527
623
|
|
|
528
624
|
# Adds a data validation rule to a cell, range, or coordinates.
|
|
529
625
|
#
|
|
530
626
|
# @param sqref [String, nil] Target cell or range reference (e.g. "B2:B100").
|
|
531
|
-
# @param opts [Hash] Validation configuration (e.g. type: :list, formula1: '"Option1,Option2"', or coordinate options `columns:`, `rows:`, `except_rows:`, `in:`).
|
|
627
|
+
# @param opts [Hash] Validation configuration (e.g. type: :list, formula1: '"Option1,Option2"', or coordinate options `columns:`, `rows:`, `except_rows:`, `list:`, `in:`).
|
|
532
628
|
# @yield [data_validation_builder] Optional configuration block.
|
|
533
629
|
# @return [void]
|
|
534
630
|
# @api public
|
|
535
631
|
#: (?String? sqref, **untyped opts) ?{ (DataValidationBuilder) -> void } -> void
|
|
536
|
-
def
|
|
632
|
+
def data_validation(sqref = nil, **opts, &)
|
|
537
633
|
normalized_list = DslHelpers.normalize_data_validation(sqref, **opts, &)
|
|
538
634
|
@data_validations.concat(normalized_list)
|
|
539
635
|
end
|
|
@@ -589,22 +685,25 @@ module Xlsxrb
|
|
|
589
685
|
# @param source_ref [String] Source data range (e.g. "DataSheet!A1:D100").
|
|
590
686
|
# @param row_fields [Array<Integer, String>] Field names or indices for row headers.
|
|
591
687
|
# @param data_fields [Array<Hash>] Data aggregation fields.
|
|
592
|
-
# @param
|
|
593
|
-
# @param
|
|
688
|
+
# @param column_fields [Array<String, Integer>, nil] Field names or indices for columns.
|
|
689
|
+
# @param ref [String, nil] Target cell for pivot table top-left corner (e.g. "E1").
|
|
594
690
|
# @param name [String, nil] Pivot table name.
|
|
595
691
|
# @param field_names [Array<String>, nil] Custom field display names.
|
|
596
|
-
# @param items [Array, nil]
|
|
692
|
+
# @param items [Hash{Integer => Array}, nil] Items of each field, by 0-based field index.
|
|
597
693
|
# @return [void]
|
|
598
694
|
# @api public
|
|
599
|
-
#: (String source_ref, row_fields: Array[String | Integer], data_fields: Array[String | Hash[Symbol, untyped]], ?
|
|
600
|
-
def pivot_table(source_ref, row_fields:, data_fields:,
|
|
695
|
+
#: (String source_ref, row_fields: Array[String | Integer], data_fields: Array[String | Hash[Symbol, untyped]], ?column_fields: Array[String | Integer]?, ?ref: String?, ?name: String?, ?field_names: Array[String]?, ?items: Hash[Integer, Array[untyped]]?, **untyped opts) -> void
|
|
696
|
+
def pivot_table(source_ref, row_fields:, data_fields:, column_fields: nil, ref: nil, name: nil, field_names: nil, items: nil, **opts)
|
|
697
|
+
c_fields = column_fields || []
|
|
698
|
+
target_ref = ref || "E1"
|
|
601
699
|
@pivot_tables ||= []
|
|
602
|
-
|
|
700
|
+
entry = {
|
|
603
701
|
source_ref: source_ref, row_fields: row_fields,
|
|
604
|
-
data_fields: data_fields,
|
|
605
|
-
|
|
702
|
+
data_fields: data_fields, column_fields: c_fields,
|
|
703
|
+
ref: target_ref, destination: target_ref, name: name,
|
|
606
704
|
field_names: field_names, items: items
|
|
607
|
-
}
|
|
705
|
+
}.merge(opts)
|
|
706
|
+
@pivot_tables << entry
|
|
608
707
|
end
|
|
609
708
|
|
|
610
709
|
# Adds a cell comment / note.
|
|
@@ -612,11 +711,14 @@ module Xlsxrb
|
|
|
612
711
|
# @param cell [String, Integer] Cell reference (e.g. "B2").
|
|
613
712
|
# @param text [String] The comment text.
|
|
614
713
|
# @param author [String] Author name.
|
|
714
|
+
# @param visible [Boolean] Whether the comment is always shown instead of on hover.
|
|
615
715
|
# @return [void]
|
|
616
716
|
# @api public
|
|
617
|
-
#: (String | Integer cell, String text, ?author: ::String) -> void
|
|
618
|
-
def comment(cell, text, author: "Author")
|
|
619
|
-
|
|
717
|
+
#: (String | Integer cell, String text, ?author: ::String, ?visible: bool) -> void
|
|
718
|
+
def comment(cell, text, author: "Author", visible: false)
|
|
719
|
+
ref_str = cell.to_s
|
|
720
|
+
@comments << { ref: ref_str, text: text, author: author, visible: visible }
|
|
721
|
+
nil
|
|
620
722
|
end
|
|
621
723
|
|
|
622
724
|
# Adds a threaded comment to a cell.
|
|
@@ -634,20 +736,24 @@ module Xlsxrb
|
|
|
634
736
|
# @api public
|
|
635
737
|
#: (String | Integer cell, String text, ?author: untyped, ?timestamp: untyped, ?id: String?, ?parent_id: String?, ?done: bool?, ?user_id: String?, ?provider_id: String?) -> void
|
|
636
738
|
def threaded_comment(cell, text, author: "Author", timestamp: nil, id: nil, parent_id: nil, done: false, user_id: nil, provider_id: nil)
|
|
739
|
+
ref_str = cell.to_s
|
|
637
740
|
entry = {
|
|
638
|
-
|
|
741
|
+
ref: ref_str,
|
|
639
742
|
text: text,
|
|
640
743
|
author: author,
|
|
641
744
|
timestamp: timestamp,
|
|
745
|
+
created_at: timestamp,
|
|
642
746
|
id: id,
|
|
643
747
|
parent_id: parent_id,
|
|
644
748
|
done: done ? true : false,
|
|
749
|
+
resolved: done ? true : false,
|
|
645
750
|
user_id: user_id,
|
|
751
|
+
author_id: user_id,
|
|
646
752
|
provider_id: provider_id
|
|
647
753
|
}.compact
|
|
648
754
|
@threaded_comments << entry
|
|
755
|
+
nil
|
|
649
756
|
end
|
|
650
|
-
alias add_threaded_comment threaded_comment
|
|
651
757
|
|
|
652
758
|
# Adds a sparkline group to the sheet.
|
|
653
759
|
#
|
|
@@ -664,103 +770,162 @@ module Xlsxrb
|
|
|
664
770
|
@sparkline_groups << group
|
|
665
771
|
end
|
|
666
772
|
|
|
667
|
-
#
|
|
668
|
-
#
|
|
669
|
-
# @example Add a line sparkline
|
|
670
|
-
# sheet.add_sparkline(location: "F1", range: "A1:E1")
|
|
671
|
-
#
|
|
672
|
-
# @example Add a column sparkline with high/low markers
|
|
673
|
-
# sheet.add_sparkline(location: "F2", range: "A2:E2", type: :column, high: true, low: true)
|
|
773
|
+
# Merges a range of cells into a single cell.
|
|
674
774
|
#
|
|
675
|
-
# @example
|
|
676
|
-
# sheet.
|
|
775
|
+
# @example Merge with string range
|
|
776
|
+
# sheet.merge("A1:C1")
|
|
677
777
|
#
|
|
678
|
-
# @param
|
|
679
|
-
# @param range [String, nil] Data range for the sparkline (e.g. "A1:E1").
|
|
680
|
-
# @param type [Symbol, String, nil] Sparkline type (:line, :column, :win_loss / :stacked).
|
|
681
|
-
# @param opts [Hash] Additional sparkline options.
|
|
778
|
+
# @param range [String] Cell range (e.g. "A1:B2").
|
|
682
779
|
# @return [void]
|
|
683
780
|
# @api public
|
|
684
|
-
#: (
|
|
685
|
-
def
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
raise ArgumentError, "Missing required location: parameter for sparkline" unless loc
|
|
689
|
-
raise ArgumentError, "Missing required range: parameter for sparkline" unless rng
|
|
690
|
-
|
|
691
|
-
mapped_type = case type&.to_s
|
|
692
|
-
when "win_loss" then "stacked"
|
|
693
|
-
when nil, "" then nil
|
|
694
|
-
else type.to_s
|
|
695
|
-
end
|
|
696
|
-
sparkline_group(sparklines: [{ data_ref: rng.to_s, location_ref: loc.to_s }], type: mapped_type, **opts)
|
|
781
|
+
#: (String range) -> void
|
|
782
|
+
def merge(range)
|
|
783
|
+
canonical = DslHelpers.normalize_merge_range(range, strict_excel_mode: @strict_excel_mode)
|
|
784
|
+
@merge_cells_ranges << canonical unless @merge_cells_ranges.include?(canonical)
|
|
697
785
|
end
|
|
698
786
|
|
|
699
|
-
#
|
|
700
|
-
#
|
|
701
|
-
# @example Merge with string range
|
|
702
|
-
# sheet.merge("A1:C1")
|
|
787
|
+
# Configures or queries freeze panes (<pane state="frozen">).
|
|
703
788
|
#
|
|
704
|
-
#
|
|
705
|
-
#
|
|
789
|
+
# When called with no arguments, returns the {Elements::FreezePane} value object or nil.
|
|
790
|
+
# When called with arguments, configures the freeze pane and returns nil.
|
|
706
791
|
#
|
|
707
|
-
# @param
|
|
708
|
-
# @param
|
|
709
|
-
# @param
|
|
710
|
-
# @param
|
|
711
|
-
# @
|
|
712
|
-
# @param row_end [Integer, nil] Ending row index.
|
|
713
|
-
# @return [void]
|
|
792
|
+
# @param row [Integer, nil] Number of rows to freeze from top (0-based split position).
|
|
793
|
+
# @param column [Integer, String, nil] Number of columns to freeze from left (0-based or letter).
|
|
794
|
+
# @param top_left_cell [String, nil] Top-left cell reference in bottom-right pane.
|
|
795
|
+
# @param active_pane [String, Symbol, nil] Active pane identifier.
|
|
796
|
+
# @return [Elements::FreezePane, nil, void]
|
|
714
797
|
# @api public
|
|
715
|
-
#: (
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
)
|
|
723
|
-
|
|
798
|
+
#: () -> Elements::FreezePane?
|
|
799
|
+
#: (?row: Integer | nil, ?column: (Integer | String)?, ?top_left_cell: String?, ?active_pane: (String | Symbol)?) -> void
|
|
800
|
+
def freeze_pane(row: nil, column: nil, top_left_cell: nil, active_pane: nil)
|
|
801
|
+
if row.nil? && column.nil? && top_left_cell.nil? && active_pane.nil?
|
|
802
|
+
return @freeze_pane ? Elements::FreezePane.new(**@freeze_pane) : nil
|
|
803
|
+
end
|
|
804
|
+
|
|
805
|
+
c = column ? Elements::Cell._column_index(column) : 0
|
|
806
|
+
entry = { row: row || 0, column: c }
|
|
807
|
+
entry[:top_left_cell] = top_left_cell if top_left_cell
|
|
808
|
+
entry[:active_pane] = active_pane.to_s if active_pane
|
|
809
|
+
@freeze_pane = entry
|
|
810
|
+
nil
|
|
724
811
|
end
|
|
725
812
|
|
|
726
|
-
#
|
|
813
|
+
# Sets or clears freeze pane configuration.
|
|
727
814
|
#
|
|
728
|
-
# @param
|
|
729
|
-
# @param col [Integer, String] Number of columns to freeze from left (0-based or letter).
|
|
815
|
+
# @param opts [Elements::FreezePane, Hash, nil] Freeze pane options.
|
|
730
816
|
# @return [void]
|
|
731
817
|
# @api public
|
|
732
|
-
#: (
|
|
733
|
-
def freeze_pane(
|
|
734
|
-
|
|
735
|
-
|
|
818
|
+
#: (Elements::FreezePane | Hash[Symbol, untyped] | nil opts) -> void
|
|
819
|
+
def freeze_pane=(opts)
|
|
820
|
+
if opts.nil?
|
|
821
|
+
@freeze_pane = nil
|
|
822
|
+
else
|
|
823
|
+
h = opts.respond_to?(:to_h) ? opts.to_h : opts
|
|
824
|
+
c = h[:column] || h[:col]
|
|
825
|
+
c = Elements::Cell._column_index(c) if c
|
|
826
|
+
entry = { row: h[:row] || 0, column: c || 0 }
|
|
827
|
+
entry[:top_left_cell] = h[:top_left_cell] if h[:top_left_cell]
|
|
828
|
+
entry[:active_pane] = h[:active_pane].to_s if h[:active_pane]
|
|
829
|
+
@freeze_pane = entry
|
|
830
|
+
end
|
|
831
|
+
nil
|
|
736
832
|
end
|
|
737
833
|
|
|
738
|
-
# Splits window panes without freezing.
|
|
834
|
+
# Splits window panes without freezing or queries split pane settings (<pane>).
|
|
835
|
+
#
|
|
836
|
+
# When called with no arguments, returns the {Elements::SplitPane} value object or nil.
|
|
837
|
+
# When called with arguments, configures the split pane and returns nil.
|
|
739
838
|
#
|
|
740
|
-
# @param x_split [Integer] Horizontal split offset in points.
|
|
741
|
-
# @param y_split [Integer] Vertical split offset in points.
|
|
839
|
+
# @param x_split [Integer, nil] Horizontal split offset in points.
|
|
840
|
+
# @param y_split [Integer, nil] Vertical split offset in points.
|
|
742
841
|
# @param top_left_cell [String, nil] Top-left cell reference in bottom-right pane.
|
|
842
|
+
# @param active_pane [String, Symbol, nil] Active pane identifier.
|
|
843
|
+
# @return [Elements::SplitPane, nil, void]
|
|
844
|
+
# @api public
|
|
845
|
+
#: () -> Elements::SplitPane?
|
|
846
|
+
#: (?x_split: Integer | nil, ?y_split: Integer | nil, ?top_left_cell: String?, ?active_pane: (String | Symbol)?) -> void
|
|
847
|
+
def split_pane(x_split: nil, y_split: nil, top_left_cell: nil, active_pane: nil)
|
|
848
|
+
if x_split.nil? && y_split.nil? && top_left_cell.nil? && active_pane.nil?
|
|
849
|
+
return @split_pane ? Elements::SplitPane.new(**@split_pane) : nil
|
|
850
|
+
end
|
|
851
|
+
|
|
852
|
+
entry = { x_split: x_split || 0, y_split: y_split || 0, top_left_cell: top_left_cell }
|
|
853
|
+
entry[:active_pane] = active_pane.to_s if active_pane
|
|
854
|
+
@split_pane = entry
|
|
855
|
+
nil
|
|
856
|
+
end
|
|
857
|
+
|
|
858
|
+
# Sets or clears split pane configuration.
|
|
859
|
+
#
|
|
860
|
+
# @param opts [Elements::SplitPane, Hash, nil] Split pane options.
|
|
743
861
|
# @return [void]
|
|
744
862
|
# @api public
|
|
745
|
-
#: (
|
|
746
|
-
def split_pane(
|
|
747
|
-
|
|
863
|
+
#: (Elements::SplitPane | Hash[Symbol, untyped] | nil opts) -> void
|
|
864
|
+
def split_pane=(opts)
|
|
865
|
+
if opts.nil?
|
|
866
|
+
@split_pane = nil
|
|
867
|
+
else
|
|
868
|
+
h = opts.respond_to?(:to_h) ? opts.to_h : opts
|
|
869
|
+
entry = { x_split: h[:x_split] || 0, y_split: h[:y_split] || 0, top_left_cell: h[:top_left_cell] }
|
|
870
|
+
entry[:active_pane] = h[:active_pane].to_s if h[:active_pane]
|
|
871
|
+
@split_pane = entry
|
|
872
|
+
end
|
|
873
|
+
nil
|
|
748
874
|
end
|
|
749
875
|
|
|
750
|
-
#
|
|
876
|
+
# Configures or queries the active cell and selection area (<selection>).
|
|
877
|
+
#
|
|
878
|
+
# When called with no arguments, returns the selection ({Elements::Selection}, Array, or nil).
|
|
879
|
+
# When called with arguments, updates the selection and returns nil.
|
|
751
880
|
#
|
|
752
|
-
# @param active_cell [String] Active cell reference (e.g. "A1").
|
|
881
|
+
# @param active_cell [String, nil] Active cell reference (e.g. "A1") or range (e.g. "A1:D10").
|
|
753
882
|
# @param sqref [String, nil] Selected range reference (e.g. "A1:D10").
|
|
754
883
|
# @param pane [String, Symbol, nil] Target pane (:topLeft, :topRight, :bottomLeft, :bottomRight).
|
|
884
|
+
# @return [Elements::Selection, Array<Elements::Selection>, nil, void]
|
|
885
|
+
# @api public
|
|
886
|
+
#: () -> (Elements::Selection | Array[Elements::Selection])?
|
|
887
|
+
#: (?String? active_cell, ?sqref: String?, ?pane: (String | Symbol)?) -> void
|
|
888
|
+
def selection(active_cell = nil, sqref: nil, pane: nil)
|
|
889
|
+
if active_cell.nil? && sqref.nil? && pane.nil?
|
|
890
|
+
return nil if @selection.nil?
|
|
891
|
+
return @selection.map { |s| Elements::Selection.new(**s) } if @selection.is_a?(Array)
|
|
892
|
+
|
|
893
|
+
return Elements::Selection.new(**@selection)
|
|
894
|
+
end
|
|
895
|
+
|
|
896
|
+
if sqref.nil? && active_cell.is_a?(String) && active_cell.include?(":")
|
|
897
|
+
sqref = active_cell
|
|
898
|
+
active_cell = sqref.split(":").first
|
|
899
|
+
else
|
|
900
|
+
sqref ||= active_cell
|
|
901
|
+
end
|
|
902
|
+
sel = { active_cell: active_cell, sqref: sqref }
|
|
903
|
+
sel[:pane] = pane if pane
|
|
904
|
+
@selection = sel
|
|
905
|
+
nil
|
|
906
|
+
end
|
|
907
|
+
|
|
908
|
+
# Sets or clears the selection configuration.
|
|
909
|
+
#
|
|
910
|
+
# @param opts [Elements::Selection, Array<Elements::Selection, Hash>, Hash, nil]
|
|
755
911
|
# @return [void]
|
|
756
912
|
# @api public
|
|
757
|
-
#: (
|
|
758
|
-
def
|
|
759
|
-
@selection =
|
|
760
|
-
|
|
913
|
+
#: (Elements::Selection | Array[Elements::Selection | Hash[Symbol, untyped]] | Hash[Symbol, untyped] | nil opts) -> void
|
|
914
|
+
def selection=(opts)
|
|
915
|
+
@selection = if opts.nil?
|
|
916
|
+
nil
|
|
917
|
+
elsif opts.is_a?(Array)
|
|
918
|
+
opts.map { |o| o.respond_to?(:to_h) ? o.to_h : o }
|
|
919
|
+
else
|
|
920
|
+
opts.respond_to?(:to_h) ? opts.to_h : opts
|
|
921
|
+
end
|
|
922
|
+
nil
|
|
761
923
|
end
|
|
762
924
|
|
|
763
|
-
#
|
|
925
|
+
# Configures or queries page margins in inches for printing (<pageMargins>).
|
|
926
|
+
#
|
|
927
|
+
# When called with no arguments, returns the {Elements::PageMargins} value object or nil.
|
|
928
|
+
# When called with arguments, configures page margins and returns nil.
|
|
764
929
|
#
|
|
765
930
|
# @param left [Float, nil] Left margin.
|
|
766
931
|
# @param right [Float, nil] Right margin.
|
|
@@ -768,68 +933,142 @@ module Xlsxrb
|
|
|
768
933
|
# @param bottom [Float, nil] Bottom margin.
|
|
769
934
|
# @param header [Float, nil] Header margin.
|
|
770
935
|
# @param footer [Float, nil] Footer margin.
|
|
771
|
-
# @return [void]
|
|
936
|
+
# @return [Elements::PageMargins, nil, void]
|
|
772
937
|
# @api public
|
|
938
|
+
#: () -> Elements::PageMargins?
|
|
773
939
|
#: (?left: Float?, ?right: Float?, ?top: Float?, ?bottom: Float?, ?header: Float?, ?footer: Float?) -> void
|
|
774
940
|
def page_margins(left: nil, right: nil, top: nil, bottom: nil, header: nil, footer: nil)
|
|
941
|
+
if left.nil? && right.nil? && top.nil? && bottom.nil? && header.nil? && footer.nil?
|
|
942
|
+
return @page_margins ? Elements::PageMargins.new(**@page_margins) : nil
|
|
943
|
+
end
|
|
944
|
+
|
|
775
945
|
@page_margins = DslHelpers.normalize_page_margins(
|
|
776
946
|
left: left, right: right, top: top, bottom: bottom, header: header, footer: footer
|
|
777
947
|
)
|
|
948
|
+
nil
|
|
778
949
|
end
|
|
779
950
|
|
|
780
|
-
# Sets page
|
|
951
|
+
# Sets or clears page margins configuration.
|
|
781
952
|
#
|
|
782
|
-
# @param opts [Hash
|
|
953
|
+
# @param opts [Hash, Elements::PageMargins, nil]
|
|
783
954
|
# @return [void]
|
|
784
955
|
# @api public
|
|
956
|
+
#: (Hash[Symbol, untyped] | Elements::PageMargins | nil opts) -> void
|
|
957
|
+
def page_margins=(opts)
|
|
958
|
+
if opts.nil?
|
|
959
|
+
@page_margins = nil
|
|
960
|
+
else
|
|
961
|
+
h = opts.respond_to?(:to_h) ? opts.to_h : opts
|
|
962
|
+
@page_margins = DslHelpers.normalize_page_margins(**h)
|
|
963
|
+
end
|
|
964
|
+
nil
|
|
965
|
+
end
|
|
966
|
+
|
|
967
|
+
# Configures or queries page setup configuration (<pageSetup>).
|
|
968
|
+
#
|
|
969
|
+
# When called with no arguments, returns the {Elements::PageSetup} value object.
|
|
970
|
+
# When called with keyword arguments, updates page setup and returns nil.
|
|
971
|
+
#
|
|
972
|
+
# @param opts [Hash] Page setup options (e.g. orientation: :landscape, paper_size: 9).
|
|
973
|
+
# @return [Elements::PageSetup, void]
|
|
974
|
+
# @api public
|
|
975
|
+
#: () -> Elements::PageSetup
|
|
785
976
|
#: (**untyped opts) -> void
|
|
786
977
|
def page_setup(**opts)
|
|
978
|
+
return Elements::PageSetup.new(**@page_setup) if opts.empty?
|
|
979
|
+
|
|
787
980
|
@page_setup.merge!(opts)
|
|
788
|
-
|
|
981
|
+
@sheet_properties[:fit_to_page] = true if (opts.key?(:fit_to_width) || opts.key?(:fit_to_height)) && !@sheet_properties.key?(:fit_to_page)
|
|
982
|
+
nil
|
|
983
|
+
end
|
|
789
984
|
|
|
790
|
-
|
|
985
|
+
# Sets page setup configuration.
|
|
986
|
+
#
|
|
987
|
+
# @param opts [Hash, Elements::PageSetup]
|
|
988
|
+
# @return [void]
|
|
989
|
+
# @api public
|
|
990
|
+
#: (Hash[Symbol, untyped] | Elements::PageSetup opts) -> void
|
|
991
|
+
def page_setup=(opts)
|
|
992
|
+
h = opts.respond_to?(:to_h) ? opts.to_h : (opts || {})
|
|
993
|
+
@page_setup = h.transform_keys(&:to_sym)
|
|
994
|
+
nil
|
|
791
995
|
end
|
|
792
996
|
|
|
793
|
-
#
|
|
794
|
-
# When enabled, optionally sets fit_to_width and/or fit_to_height on page_setup.
|
|
997
|
+
# Returns whether page setup fits content to page width/height.
|
|
795
998
|
#
|
|
796
|
-
# @
|
|
797
|
-
# @
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
def fit_to_page(enabled = nil, width: nil, height: nil)
|
|
803
|
-
if enabled.nil? && width.nil? && height.nil?
|
|
804
|
-
return @sheet_properties[:fit_to_page] ? true : false
|
|
805
|
-
end
|
|
999
|
+
# @return [Boolean]
|
|
1000
|
+
# @api public
|
|
1001
|
+
#: () -> bool
|
|
1002
|
+
def fit_to_page?
|
|
1003
|
+
@sheet_properties[:fit_to_page] ? true : false
|
|
1004
|
+
end
|
|
806
1005
|
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
1006
|
+
# Sets whether page setup fits content to page width/height.
|
|
1007
|
+
#
|
|
1008
|
+
# @param enabled [Boolean, nil] Whether to fit to page.
|
|
1009
|
+
# @return [Boolean]
|
|
1010
|
+
# @api public
|
|
1011
|
+
#: (bool? enabled) -> bool?
|
|
1012
|
+
def fit_to_page=(enabled)
|
|
1013
|
+
@sheet_properties[:fit_to_page] = enabled ? true : false
|
|
810
1014
|
end
|
|
811
|
-
alias fit_to_page= fit_to_page
|
|
812
|
-
alias fit_to_page? fit_to_page
|
|
813
1015
|
|
|
814
|
-
# Configures headers and footers for printing.
|
|
1016
|
+
# Configures or queries headers and footers for printing (<headerFooter>).
|
|
1017
|
+
#
|
|
1018
|
+
# When called with no arguments, returns the {Elements::HeaderFooter} value object.
|
|
1019
|
+
# When called with keyword arguments, updates headers and footers and returns nil.
|
|
815
1020
|
#
|
|
816
1021
|
# @param opts [Hash] Header and footer options (e.g. odd_header: "&CHeader Text").
|
|
817
|
-
# @return [void]
|
|
1022
|
+
# @return [Elements::HeaderFooter, void]
|
|
818
1023
|
# @api public
|
|
1024
|
+
#: () -> Elements::HeaderFooter
|
|
819
1025
|
#: (**untyped opts) -> void
|
|
820
1026
|
def header_footer(**opts)
|
|
1027
|
+
return Elements::HeaderFooter.new(**@header_footer) if opts.empty?
|
|
1028
|
+
|
|
821
1029
|
@header_footer.merge!(opts)
|
|
1030
|
+
nil
|
|
822
1031
|
end
|
|
823
1032
|
|
|
824
|
-
# Sets
|
|
1033
|
+
# Sets header and footer configuration.
|
|
825
1034
|
#
|
|
826
|
-
# @param
|
|
827
|
-
# @param value [Object] Option value.
|
|
1035
|
+
# @param opts [Hash, Elements::HeaderFooter]
|
|
828
1036
|
# @return [void]
|
|
829
1037
|
# @api public
|
|
830
|
-
#: (Symbol
|
|
831
|
-
def
|
|
832
|
-
|
|
1038
|
+
#: (Hash[Symbol, untyped] | Elements::HeaderFooter opts) -> void
|
|
1039
|
+
def header_footer=(opts)
|
|
1040
|
+
h = opts.respond_to?(:to_h) ? opts.to_h : (opts || {})
|
|
1041
|
+
@header_footer = h.transform_keys(&:to_sym)
|
|
1042
|
+
nil
|
|
1043
|
+
end
|
|
1044
|
+
|
|
1045
|
+
# Configures or queries print options (<printOptions>).
|
|
1046
|
+
#
|
|
1047
|
+
# When called with no arguments, returns the {Elements::PrintOptions} value object.
|
|
1048
|
+
# When called with keyword options, configures print options and returns nil.
|
|
1049
|
+
#
|
|
1050
|
+
# @param opts [Hash] Additional print options.
|
|
1051
|
+
# @return [Elements::PrintOptions, void]
|
|
1052
|
+
# @api public
|
|
1053
|
+
#: () -> Elements::PrintOptions
|
|
1054
|
+
#: (**untyped opts) -> void
|
|
1055
|
+
def print_options(**opts)
|
|
1056
|
+
return Elements::PrintOptions.new(**@print_options) if opts.empty?
|
|
1057
|
+
|
|
1058
|
+
opts.each { |k, v| @print_options[k.to_sym] = v }
|
|
1059
|
+
nil
|
|
1060
|
+
end
|
|
1061
|
+
|
|
1062
|
+
# Replaces print options with the given hash or {Elements::PrintOptions} object.
|
|
1063
|
+
#
|
|
1064
|
+
# @param opts [Hash, Elements::PrintOptions]
|
|
1065
|
+
# @return [void]
|
|
1066
|
+
# @api public
|
|
1067
|
+
#: (Hash[Symbol, untyped] | Elements::PrintOptions opts) -> void
|
|
1068
|
+
def print_options=(opts)
|
|
1069
|
+
h = opts.respond_to?(:to_h) ? opts.to_h : (opts || {})
|
|
1070
|
+
@print_options = h.transform_keys(&:to_sym)
|
|
1071
|
+
nil
|
|
833
1072
|
end
|
|
834
1073
|
|
|
835
1074
|
# Adds a defined name (named range or formula) scoped to this sheet or workbook.
|
|
@@ -838,57 +1077,85 @@ module Xlsxrb
|
|
|
838
1077
|
# @param name [String] Defined name identifier.
|
|
839
1078
|
# @param value [Object, nil] Cell reference, formula, or constant.
|
|
840
1079
|
# @param hidden [Boolean] Whether the defined name is hidden from Excel's UI.
|
|
841
|
-
# @param
|
|
842
|
-
# @param rows [Integer, Range, nil] Row or row range (
|
|
1080
|
+
# @param columns [Integer, String, nil] Column index or letter for coordinate-based reference.
|
|
1081
|
+
# @param rows [Integer, Range, nil] Row or row range (0-based) for coordinate-based reference.
|
|
843
1082
|
# @param range [String, nil] Cell range reference (e.g. "A1:A10").
|
|
844
|
-
# @param sheet [String, nil]
|
|
1083
|
+
# @param sheet [String, nil] Reference sheet name (defaults to current sheet).
|
|
1084
|
+
# @param scope [String, Symbol, nil] Scope identifier (:workbook or sheet name).
|
|
845
1085
|
# @return [void]
|
|
846
1086
|
# @api public
|
|
847
|
-
#: (String name, ?untyped value, ?hidden: bool, ?
|
|
848
|
-
def defined_name(name, value = nil, hidden: false,
|
|
1087
|
+
#: (String name, ?untyped value, ?hidden: bool, ?columns: untyped, ?rows: untyped, ?range: untyped, ?sheet: String?, ?scope: (String | Symbol)?) -> void
|
|
1088
|
+
def defined_name(name, value = nil, hidden: false, columns: nil, rows: nil, range: nil, sheet: nil, scope: nil)
|
|
849
1089
|
ref_sheet = sheet || @name
|
|
850
|
-
normalized_val = DslHelpers.normalize_defined_name_value(value, sheet: ref_sheet,
|
|
1090
|
+
normalized_val = DslHelpers.normalize_defined_name_value(value, sheet: ref_sheet, columns: columns, rows: rows, range: range)
|
|
851
1091
|
entry = { name: name, value: normalized_val, hidden: hidden }
|
|
852
|
-
local_sheet =
|
|
1092
|
+
local_sheet = if scope
|
|
1093
|
+
scope == :workbook ? nil : scope.to_s
|
|
1094
|
+
end
|
|
853
1095
|
entry[:local_sheet_name] = local_sheet if local_sheet
|
|
854
1096
|
@defined_names << entry
|
|
855
1097
|
end
|
|
856
1098
|
|
|
857
|
-
#
|
|
858
|
-
#
|
|
859
|
-
# @example Set print area range
|
|
860
|
-
# sheet.print_area("A1:H50")
|
|
1099
|
+
# Returns the print area for the worksheet, or nil if none.
|
|
861
1100
|
#
|
|
862
1101
|
# @example Get print area range
|
|
863
1102
|
# sheet.print_area #=> "A1:H50"
|
|
864
1103
|
#
|
|
865
|
-
# @param range [String, nil] Cell range (e.g. "A1:H50").
|
|
866
1104
|
# @return [String, nil]
|
|
867
1105
|
# @api public
|
|
868
|
-
#: (
|
|
869
|
-
|
|
870
|
-
return @print_area if range.nil?
|
|
1106
|
+
#: () -> String?
|
|
1107
|
+
attr_reader :print_area
|
|
871
1108
|
|
|
872
|
-
|
|
1109
|
+
# Sets the print area for the worksheet.
|
|
1110
|
+
#
|
|
1111
|
+
# @param range [String, nil] Cell range (e.g. "A1:H50").
|
|
1112
|
+
# @return [String, nil]
|
|
1113
|
+
# @api public
|
|
1114
|
+
#: (String? range) -> String?
|
|
1115
|
+
def print_area=(range)
|
|
1116
|
+
@print_area = range&.to_s
|
|
873
1117
|
end
|
|
874
1118
|
|
|
875
1119
|
# Sets or gets repeating print titles (rows and/or columns) for pagination.
|
|
876
1120
|
#
|
|
1121
|
+
# When called with no arguments, returns the {Elements::PrintTitles} value object or nil.
|
|
1122
|
+
# When called with arguments, updates print titles and returns nil.
|
|
1123
|
+
#
|
|
877
1124
|
# @example Set repeating header rows
|
|
878
1125
|
# sheet.print_titles(rows: "1:2")
|
|
879
1126
|
#
|
|
880
1127
|
# @example Get repeating print titles
|
|
881
|
-
# sheet.print_titles #=>
|
|
1128
|
+
# sheet.print_titles #=> #<Xlsxrb::Elements::PrintTitles ...>
|
|
882
1129
|
#
|
|
883
|
-
# @param rows [String, nil] Repeating row range (e.g. "1:2").
|
|
884
|
-
# @param
|
|
885
|
-
# @return [
|
|
1130
|
+
# @param rows [String, Integer, Range, nil] Repeating row range (e.g. "1:2" or 0-based 0..1).
|
|
1131
|
+
# @param columns [String, Integer, Symbol, Range, nil] Repeating column range (e.g. "A:B" or 0..1).
|
|
1132
|
+
# @return [Elements::PrintTitles, nil, void]
|
|
886
1133
|
# @api public
|
|
887
|
-
#: (
|
|
888
|
-
|
|
889
|
-
|
|
1134
|
+
#: () -> Elements::PrintTitles?
|
|
1135
|
+
#: (?rows: (String | Integer | Range[Integer])?, ?columns: (String | Integer | Symbol | Range[untyped])?) -> void
|
|
1136
|
+
def print_titles(rows: nil, columns: nil)
|
|
1137
|
+
return @print_titles ? Elements::PrintTitles.new(**@print_titles) : nil if rows.nil? && columns.nil?
|
|
890
1138
|
|
|
891
|
-
|
|
1139
|
+
norm_rows = DslHelpers.normalize_print_titles_rows(rows)
|
|
1140
|
+
norm_cols = DslHelpers.normalize_print_titles_columns(columns)
|
|
1141
|
+
@print_titles = Elements::PrintTitles.new(rows: norm_rows, columns: norm_cols)
|
|
1142
|
+
nil
|
|
1143
|
+
end
|
|
1144
|
+
|
|
1145
|
+
# Sets repeating print titles for the worksheet.
|
|
1146
|
+
#
|
|
1147
|
+
# @param opts [Elements::PrintTitles, Hash, nil] Options with :rows and/or :columns.
|
|
1148
|
+
# @return [Elements::PrintTitles, Hash, nil]
|
|
1149
|
+
# @api public
|
|
1150
|
+
#: (Elements::PrintTitles | Hash[Symbol, untyped] | nil opts) -> (Elements::PrintTitles | Hash[Symbol, untyped] | nil)
|
|
1151
|
+
def print_titles=(opts)
|
|
1152
|
+
if opts.nil?
|
|
1153
|
+
@print_titles = nil
|
|
1154
|
+
else
|
|
1155
|
+
h = opts.respond_to?(:to_h) ? opts.to_h : opts
|
|
1156
|
+
print_titles(**h)
|
|
1157
|
+
end
|
|
1158
|
+
opts
|
|
892
1159
|
end
|
|
893
1160
|
|
|
894
1161
|
# Sets repeating title rows to appear at the top of each printed page.
|
|
@@ -912,7 +1179,8 @@ module Xlsxrb
|
|
|
912
1179
|
last ||= first
|
|
913
1180
|
"#{first + 1}:#{last + 1}"
|
|
914
1181
|
end
|
|
915
|
-
|
|
1182
|
+
existing_cols = @print_titles&.columns
|
|
1183
|
+
print_titles(rows: rows_str, columns: existing_cols)
|
|
916
1184
|
end
|
|
917
1185
|
|
|
918
1186
|
# Sets repeating title columns to appear at the left of each printed page.
|
|
@@ -933,9 +1201,9 @@ module Xlsxrb
|
|
|
933
1201
|
cols_str = if first.is_a?(String)
|
|
934
1202
|
first.include?(":") ? first : "#{first}:#{last || first}"
|
|
935
1203
|
else
|
|
936
|
-
first_name =
|
|
1204
|
+
first_name = Elements::Cell._column_letter(first)
|
|
937
1205
|
last_name = if last.is_a?(Integer)
|
|
938
|
-
|
|
1206
|
+
Elements::Cell._column_letter(last)
|
|
939
1207
|
elsif last
|
|
940
1208
|
last.to_s
|
|
941
1209
|
else
|
|
@@ -943,55 +1211,91 @@ module Xlsxrb
|
|
|
943
1211
|
end
|
|
944
1212
|
"#{first_name}:#{last_name}"
|
|
945
1213
|
end
|
|
946
|
-
|
|
1214
|
+
existing_rows = @print_titles&.rows
|
|
1215
|
+
print_titles(rows: existing_rows, columns: cols_str)
|
|
947
1216
|
end
|
|
948
1217
|
|
|
949
|
-
# Sets sheet-level protection with optional password hashing.
|
|
1218
|
+
# Sets or queries sheet-level protection with optional password hashing (<sheetProtection>).
|
|
1219
|
+
#
|
|
1220
|
+
# When called with no arguments, returns the {Elements::SheetProtection} value object or nil.
|
|
1221
|
+
# When called with keyword arguments, sets sheet protection and returns nil.
|
|
950
1222
|
#
|
|
951
1223
|
# @param opts [Hash] Protection options (e.g. password: "secret", select_locked_cells: true).
|
|
952
|
-
# @return [void]
|
|
1224
|
+
# @return [Elements::SheetProtection, nil, void]
|
|
953
1225
|
# @api public
|
|
1226
|
+
#: () -> Elements::SheetProtection?
|
|
954
1227
|
#: (**untyped opts) -> void
|
|
955
|
-
def
|
|
956
|
-
|
|
1228
|
+
def sheet_protection(**opts)
|
|
1229
|
+
if opts.empty?
|
|
1230
|
+
@sheet_protection ? Elements::SheetProtection.new(**@sheet_protection) : nil
|
|
1231
|
+
else
|
|
1232
|
+
@sheet_protection = DslHelpers.normalize_protection_options(opts)
|
|
1233
|
+
nil
|
|
1234
|
+
end
|
|
1235
|
+
end
|
|
1236
|
+
|
|
1237
|
+
# Sets or clears sheet protection configuration.
|
|
1238
|
+
#
|
|
1239
|
+
# @param opts [Elements::SheetProtection, Hash, Boolean, nil]
|
|
1240
|
+
# @return [void]
|
|
1241
|
+
# @api public
|
|
1242
|
+
#: (Elements::SheetProtection | Hash[Symbol, untyped] | bool | nil opts) -> void
|
|
1243
|
+
def sheet_protection=(opts)
|
|
1244
|
+
if opts.nil? || opts == false
|
|
1245
|
+
@sheet_protection = nil
|
|
1246
|
+
elsif opts == true
|
|
1247
|
+
@sheet_protection = DslHelpers.normalize_protection_options(sheet: true)
|
|
1248
|
+
else
|
|
1249
|
+
h = opts.respond_to?(:to_h) ? opts.to_h : opts
|
|
1250
|
+
@sheet_protection = DslHelpers.normalize_protection_options(h)
|
|
1251
|
+
end
|
|
1252
|
+
nil
|
|
957
1253
|
end
|
|
958
1254
|
|
|
959
1255
|
# Inserts an embedded image from raw binary data.
|
|
960
1256
|
#
|
|
961
1257
|
# @param file_data [String] Binary image data.
|
|
962
1258
|
# @param ext [String] File extension ("png", "jpeg", etc.).
|
|
963
|
-
# @param
|
|
1259
|
+
# @param from_column [Integer, nil] Top-left starting column (0-based).
|
|
964
1260
|
# @param from_row [Integer] Top-left starting row (0-based).
|
|
965
|
-
# @param
|
|
1261
|
+
# @param to_column [Integer, nil] Bottom-right ending column (0-based).
|
|
966
1262
|
# @param to_row [Integer] Bottom-right ending row (0-based).
|
|
967
1263
|
# @param opts [Hash] Additional image anchoring options.
|
|
968
1264
|
# @return [void]
|
|
969
1265
|
# @api public
|
|
970
|
-
#: (String file_data, ?ext: ::String, ?
|
|
971
|
-
def image(file_data, ext: "png",
|
|
972
|
-
|
|
1266
|
+
#: (String file_data, ?ext: ::String, ?from_column: ::Integer?, ?from_row: ::Integer, ?to_column: ::Integer?, ?to_row: ::Integer, **untyped opts) -> void
|
|
1267
|
+
def image(file_data, ext: "png", from_column: nil, from_row: 0, to_column: nil, to_row: 10, **opts)
|
|
1268
|
+
fc = from_column || 0
|
|
1269
|
+
tc = to_column || 5
|
|
1270
|
+
img = { file_data: file_data, ext: ext, from_column: fc, from_row: from_row, to_column: tc, to_row: to_row }
|
|
973
1271
|
img.merge!(opts)
|
|
974
1272
|
@images << img
|
|
975
1273
|
end
|
|
976
1274
|
|
|
977
|
-
#
|
|
978
|
-
#
|
|
979
|
-
# @example Set background image from binary data
|
|
980
|
-
# sheet.background_image(png_bytes, ext: "png")
|
|
1275
|
+
# Gets the worksheet background image (<picture>).
|
|
981
1276
|
#
|
|
982
|
-
# @
|
|
983
|
-
#
|
|
1277
|
+
# @return [Elements::BackgroundImage, nil]
|
|
1278
|
+
# @api public
|
|
1279
|
+
#: () -> Elements::BackgroundImage?
|
|
1280
|
+
def background_image
|
|
1281
|
+
return nil unless @background_image
|
|
1282
|
+
|
|
1283
|
+
@background_image.is_a?(Elements::BackgroundImage) ? @background_image : Elements::BackgroundImage.new(**@background_image)
|
|
1284
|
+
end
|
|
1285
|
+
|
|
1286
|
+
# Sets the worksheet background image (<picture>).
|
|
984
1287
|
#
|
|
985
|
-
# @param
|
|
986
|
-
# @
|
|
987
|
-
# @param opts [Hash] Additional image options.
|
|
988
|
-
# @return [Hash, nil]
|
|
1288
|
+
# @param val [String, Hash, Elements::Image, nil] Image binary data, file path, or image options hash.
|
|
1289
|
+
# @return [untyped]
|
|
989
1290
|
# @api public
|
|
990
|
-
#: (
|
|
991
|
-
def background_image(
|
|
992
|
-
|
|
1291
|
+
#: (untyped val) -> untyped
|
|
1292
|
+
def background_image=(val)
|
|
1293
|
+
if val.nil?
|
|
1294
|
+
@background_image = nil
|
|
1295
|
+
return
|
|
1296
|
+
end
|
|
993
1297
|
|
|
994
|
-
data =
|
|
1298
|
+
data = val
|
|
995
1299
|
inferred_ext = nil
|
|
996
1300
|
if data.is_a?(String) && !data.include?("\x00") && File.file?(data)
|
|
997
1301
|
inferred_ext = File.extname(data).delete_prefix(".").downcase
|
|
@@ -1004,7 +1308,7 @@ module Xlsxrb
|
|
|
1004
1308
|
data = data.data
|
|
1005
1309
|
end
|
|
1006
1310
|
|
|
1007
|
-
final_ext = (
|
|
1311
|
+
final_ext = (inferred_ext || (val.is_a?(Hash) ? val[:ext] : nil) || "png").to_s.delete_prefix(".").downcase
|
|
1008
1312
|
mime = case final_ext
|
|
1009
1313
|
when "png" then "image/png"
|
|
1010
1314
|
when "jpg", "jpeg" then "image/jpeg"
|
|
@@ -1015,162 +1319,203 @@ module Xlsxrb
|
|
|
1015
1319
|
else "application/octet-stream"
|
|
1016
1320
|
end
|
|
1017
1321
|
|
|
1322
|
+
opts = val.is_a?(Hash) ? val : {}
|
|
1018
1323
|
@background_image = {
|
|
1019
1324
|
data: data&.b,
|
|
1020
1325
|
file_data: data&.b,
|
|
1326
|
+
extension: final_ext,
|
|
1021
1327
|
ext: final_ext,
|
|
1328
|
+
path: "background.#{final_ext}",
|
|
1022
1329
|
filename: "background.#{final_ext}",
|
|
1023
1330
|
content_type: mime
|
|
1024
1331
|
}.merge(opts).freeze
|
|
1332
|
+
val
|
|
1025
1333
|
end
|
|
1026
|
-
alias background_picture background_image
|
|
1027
|
-
alias picture background_image
|
|
1028
|
-
|
|
1029
|
-
def background_image=(val)
|
|
1030
|
-
background_image(val)
|
|
1031
|
-
end
|
|
1032
|
-
alias background_picture= background_image=
|
|
1033
|
-
alias picture= background_image=
|
|
1034
1334
|
|
|
1035
1335
|
# Inserts a drawing shape (e.g. rectangle, callout, arrow).
|
|
1036
1336
|
#
|
|
1037
1337
|
# @param preset [String] Shape preset name (e.g. "rect", "roundRect").
|
|
1038
1338
|
# @param text [String, nil] Shape label text.
|
|
1039
|
-
# @param
|
|
1339
|
+
# @param from_column [Integer, nil] Top-left column.
|
|
1040
1340
|
# @param from_row [Integer] Top-left row.
|
|
1041
|
-
# @param
|
|
1341
|
+
# @param to_column [Integer, nil] Bottom-right column.
|
|
1042
1342
|
# @param to_row [Integer] Bottom-right row.
|
|
1043
1343
|
# @param opts [Hash] Additional shape formatting options.
|
|
1044
1344
|
# @return [void]
|
|
1045
1345
|
# @api public
|
|
1046
|
-
#: (**untyped opts) -> void
|
|
1047
|
-
def shape(preset: "rect", text: nil,
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
@shapes
|
|
1346
|
+
#: (?preset: String, ?text: String?, ?from_column: Integer?, ?from_row: Integer, ?to_column: Integer?, ?to_row: Integer, **untyped opts) -> void
|
|
1347
|
+
def shape(preset: "rect", text: nil, from_column: nil, from_row: 0, to_column: nil, to_row: 5, **opts)
|
|
1348
|
+
fc = from_column || 0
|
|
1349
|
+
tc = to_column || 5
|
|
1350
|
+
shape_data = { preset: preset, text: text, from_column: fc, from_row: from_row, to_column: tc, to_row: to_row }
|
|
1351
|
+
shape_data[:name] = opts.delete(:name) || "Shape #{@shapes.size + 1}"
|
|
1352
|
+
shape_data.merge!(opts)
|
|
1353
|
+
@shapes << shape_data
|
|
1052
1354
|
end
|
|
1053
1355
|
|
|
1054
|
-
# Gets
|
|
1356
|
+
# Gets the sheet visibility state (:visible, :hidden, or :very_hidden).
|
|
1055
1357
|
#
|
|
1056
|
-
# @param new_state [Symbol, nil] The new state.
|
|
1057
1358
|
# @return [Symbol]
|
|
1058
1359
|
# @api public
|
|
1059
|
-
#:
|
|
1060
|
-
|
|
1061
|
-
if new_state
|
|
1062
|
-
val = new_state.to_sym
|
|
1063
|
-
raise ArgumentError, "Invalid sheet state ':#{val}'. Allowed states are :visible, :hidden, :very_hidden" unless VALID_SHEET_STATES.include?(val)
|
|
1360
|
+
#: Symbol
|
|
1361
|
+
attr_reader :state
|
|
1064
1362
|
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1363
|
+
# Sets the sheet visibility state (:visible, :hidden, or :very_hidden).
|
|
1364
|
+
#
|
|
1365
|
+
# @param new_state [Symbol, String] The new state.
|
|
1366
|
+
# @return [Symbol]
|
|
1367
|
+
# @api public
|
|
1368
|
+
#: (Symbol | String new_state) -> Symbol
|
|
1369
|
+
def state=(new_state)
|
|
1370
|
+
val = new_state.to_sym
|
|
1371
|
+
raise ArgumentError, "Invalid sheet state ':#{val}'. Allowed states are :visible, :hidden, :very_hidden" unless VALID_SHEET_STATES.include?(val)
|
|
1372
|
+
|
|
1373
|
+
@state = val
|
|
1069
1374
|
end
|
|
1070
1375
|
|
|
1071
|
-
# Gets
|
|
1376
|
+
# Gets the worksheet tab color.
|
|
1072
1377
|
#
|
|
1073
|
-
# @
|
|
1074
|
-
# Returns the current tab color specification.
|
|
1075
|
-
# @return [String, Hash, nil]
|
|
1076
|
-
# @overload tab_color(spec, **opts)
|
|
1077
|
-
# Sets the tab color using an RGB hex string or color options.
|
|
1078
|
-
# @param spec [String, Hash, Symbol, nil] RGB hex string (e.g. "FF0000"), theme/indexed hash, or nil.
|
|
1079
|
-
# @param opts [Hash] Color keyword arguments (e.g. theme: 1, tint: 0.5, indexed: 9, auto: true).
|
|
1080
|
-
# @return [String, Hash, nil]
|
|
1378
|
+
# @return [String, Hash, nil]
|
|
1081
1379
|
# @api public
|
|
1082
|
-
#: (
|
|
1083
|
-
def tab_color
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1380
|
+
#: () -> (String | Hash[Symbol, untyped] | nil)
|
|
1381
|
+
def tab_color
|
|
1382
|
+
@sheet_properties[:tab_color]
|
|
1383
|
+
end
|
|
1384
|
+
|
|
1385
|
+
# Sets the tab color of this worksheet.
|
|
1386
|
+
#
|
|
1387
|
+
# @param spec [String, Hash, Symbol, nil] Tab color hex string (e.g. "FF0000") or hash options.
|
|
1388
|
+
# @return [String, Hash, nil]
|
|
1389
|
+
# @api public
|
|
1390
|
+
#: (String | Symbol | Hash[Symbol, untyped] | nil spec) -> (String | Hash[Symbol, untyped] | nil)
|
|
1391
|
+
def tab_color=(spec)
|
|
1392
|
+
@sheet_properties[:tab_color] = spec
|
|
1393
|
+
end
|
|
1394
|
+
|
|
1395
|
+
# Sets a single sheet property.
|
|
1396
|
+
#
|
|
1397
|
+
# Configures or queries sheet properties (<sheetPr>).
|
|
1398
|
+
#
|
|
1399
|
+
# When called with no arguments, returns the {Elements::SheetProperties} value object.
|
|
1400
|
+
# When called with keyword options, configures properties and returns nil.
|
|
1401
|
+
#
|
|
1402
|
+
# @param opts [Hash] Additional sheet properties.
|
|
1403
|
+
# @return [Elements::SheetProperties, void]
|
|
1404
|
+
# @api public
|
|
1405
|
+
#: () -> Elements::SheetProperties
|
|
1406
|
+
#: (**untyped opts) -> void
|
|
1407
|
+
def sheet_properties(**opts)
|
|
1408
|
+
return Elements::SheetProperties.new(**@sheet_properties) if opts.empty?
|
|
1409
|
+
|
|
1410
|
+
opts.each do |k, v|
|
|
1411
|
+
sym = k.to_sym
|
|
1412
|
+
if sym == :state
|
|
1413
|
+
val = v.to_sym
|
|
1414
|
+
raise ArgumentError, "Invalid sheet state ':#{val}'. Allowed states are :visible, :hidden, :very_hidden" unless VALID_SHEET_STATES.include?(val)
|
|
1415
|
+
|
|
1416
|
+
@state = val
|
|
1417
|
+
elsif sym == :hidden
|
|
1418
|
+
@state = v ? :hidden : :visible
|
|
1419
|
+
else
|
|
1420
|
+
@sheet_properties[sym] = v
|
|
1421
|
+
end
|
|
1093
1422
|
end
|
|
1423
|
+
nil
|
|
1094
1424
|
end
|
|
1095
|
-
alias tab_color= tab_color
|
|
1096
1425
|
|
|
1097
|
-
#
|
|
1426
|
+
# Replaces worksheet properties with the given hash or {Elements::SheetProperties} object.
|
|
1098
1427
|
#
|
|
1099
|
-
# @param
|
|
1100
|
-
# @param value [Object] Property value.
|
|
1428
|
+
# @param opts [Hash, Elements::SheetProperties]
|
|
1101
1429
|
# @return [void]
|
|
1102
1430
|
# @api public
|
|
1103
|
-
#: (Symbol
|
|
1104
|
-
def sheet_properties(
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1431
|
+
#: (Hash[Symbol, untyped] | Elements::SheetProperties opts) -> void
|
|
1432
|
+
def sheet_properties=(opts)
|
|
1433
|
+
h = opts.respond_to?(:to_h) ? opts.to_h : (opts || {})
|
|
1434
|
+
@sheet_properties = {}
|
|
1435
|
+
sheet_properties(**h)
|
|
1436
|
+
nil
|
|
1437
|
+
end
|
|
1109
1438
|
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1439
|
+
# Configures or queries sheet view display properties (<sheetView>).
|
|
1440
|
+
#
|
|
1441
|
+
# When called with no arguments, returns the {Elements::SheetView} value object.
|
|
1442
|
+
# When called with keyword options, configures view properties and returns nil.
|
|
1443
|
+
#
|
|
1444
|
+
# @param opts [Hash] Additional view properties.
|
|
1445
|
+
# @return [Elements::SheetView, void]
|
|
1446
|
+
# @api public
|
|
1447
|
+
#: () -> Elements::SheetView
|
|
1448
|
+
#: (**untyped opts) -> void
|
|
1449
|
+
def sheet_view(**opts)
|
|
1450
|
+
return Elements::SheetView.new(**@sheet_view) if opts.empty?
|
|
1116
1451
|
|
|
1117
|
-
@
|
|
1452
|
+
opts.each { |k, v| @sheet_view[k.to_sym] = v }
|
|
1453
|
+
nil
|
|
1118
1454
|
end
|
|
1119
1455
|
|
|
1120
|
-
#
|
|
1456
|
+
# Replaces sheet view properties with the given hash or {Elements::SheetView} object.
|
|
1121
1457
|
#
|
|
1122
|
-
# @param
|
|
1123
|
-
# @param value [Object] View property value.
|
|
1458
|
+
# @param opts [Hash, Elements::SheetView]
|
|
1124
1459
|
# @return [void]
|
|
1125
1460
|
# @api public
|
|
1126
|
-
#: (Symbol
|
|
1127
|
-
def sheet_view(
|
|
1128
|
-
|
|
1461
|
+
#: (Hash[Symbol, untyped] | Elements::SheetView opts) -> void
|
|
1462
|
+
def sheet_view=(opts)
|
|
1463
|
+
h = opts.respond_to?(:to_h) ? opts.to_h : (opts || {})
|
|
1464
|
+
@sheet_view = h.transform_keys(&:to_sym)
|
|
1465
|
+
nil
|
|
1129
1466
|
end
|
|
1130
1467
|
|
|
1131
|
-
# Configures sheet format properties (
|
|
1468
|
+
# Configures or queries sheet format properties (<sheetFormatPr>).
|
|
1132
1469
|
#
|
|
1133
|
-
#
|
|
1134
|
-
#
|
|
1470
|
+
# When called with no arguments, returns the {Elements::SheetFormat} value object.
|
|
1471
|
+
# When called with keyword options, configures format properties and returns nil.
|
|
1135
1472
|
#
|
|
1136
|
-
# @example Using
|
|
1137
|
-
# sheet.sheet_format(:
|
|
1473
|
+
# @example Using keyword arguments
|
|
1474
|
+
# sheet.sheet_format(default_row_height: 24, default_column_width: 15)
|
|
1138
1475
|
#
|
|
1139
|
-
# @param name [Symbol, String, Hash, nil] Property name or hash of properties.
|
|
1140
|
-
# @param value [Object, nil] Property value when name is provided.
|
|
1141
1476
|
# @param opts [Hash] Keyword arguments for sheet format properties.
|
|
1142
|
-
# @return [
|
|
1143
|
-
# @api public
|
|
1144
|
-
#: (
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
@sheet_format.merge!(opts) unless opts.empty?
|
|
1152
|
-
@sheet_format
|
|
1477
|
+
# @return [Elements::SheetFormat, void]
|
|
1478
|
+
# @api public
|
|
1479
|
+
#: () -> Elements::SheetFormat
|
|
1480
|
+
#: (**untyped opts) -> void
|
|
1481
|
+
def sheet_format(**opts)
|
|
1482
|
+
return Elements::SheetFormat.new(**@sheet_format) if opts.empty?
|
|
1483
|
+
|
|
1484
|
+
opts.each { |k, v| @sheet_format[k.to_sym] = v }
|
|
1485
|
+
nil
|
|
1153
1486
|
end
|
|
1154
1487
|
|
|
1155
|
-
#
|
|
1488
|
+
# Replaces sheet format properties with the given hash or {Elements::SheetFormat} object.
|
|
1156
1489
|
#
|
|
1157
|
-
# @param
|
|
1490
|
+
# @param opts [Hash, Elements::SheetFormat]
|
|
1158
1491
|
# @return [void]
|
|
1159
1492
|
# @api public
|
|
1160
|
-
#: (
|
|
1161
|
-
def
|
|
1162
|
-
|
|
1493
|
+
#: (Hash[Symbol, untyped] | Elements::SheetFormat opts) -> void
|
|
1494
|
+
def sheet_format=(opts)
|
|
1495
|
+
h = opts.respond_to?(:to_h) ? opts.to_h : (opts || {})
|
|
1496
|
+
@sheet_format = h.transform_keys(&:to_sym)
|
|
1497
|
+
nil
|
|
1163
1498
|
end
|
|
1164
1499
|
|
|
1165
|
-
# Inserts a
|
|
1500
|
+
# Inserts a horizontal page break after the specified 0-based row.
|
|
1166
1501
|
#
|
|
1167
|
-
# @param
|
|
1502
|
+
# @param row_index [Integer] 0-based row index.
|
|
1168
1503
|
# @return [void]
|
|
1169
1504
|
# @api public
|
|
1170
|
-
#: (Integer
|
|
1171
|
-
def
|
|
1172
|
-
|
|
1173
|
-
|
|
1505
|
+
#: (Integer row_index) -> void
|
|
1506
|
+
def row_break(row_index)
|
|
1507
|
+
@row_breaks << { id: row_index, max: 16_383, man: 1 }
|
|
1508
|
+
end
|
|
1509
|
+
|
|
1510
|
+
# Inserts a vertical page break after the specified column.
|
|
1511
|
+
#
|
|
1512
|
+
# @param col [Integer, String, Symbol] Column index (0-based) or letter ("B", :B).
|
|
1513
|
+
# @return [void]
|
|
1514
|
+
# @api public
|
|
1515
|
+
#: (Integer | String | Symbol col) -> void
|
|
1516
|
+
def column_break(col)
|
|
1517
|
+
col_index = Elements::Cell._column_index(col)
|
|
1518
|
+
@col_breaks << { id: col_index, max: 1_048_575, man: 1 }
|
|
1174
1519
|
end
|
|
1175
1520
|
|
|
1176
1521
|
# Adds a protected range to the worksheet.
|
|
@@ -1188,7 +1533,6 @@ module Xlsxrb
|
|
|
1188
1533
|
entry.merge!(opts) unless opts.empty?
|
|
1189
1534
|
@protected_ranges << DslHelpers.normalize_protection_options(entry)
|
|
1190
1535
|
end
|
|
1191
|
-
alias add_protected_range protected_range
|
|
1192
1536
|
|
|
1193
1537
|
# Adds a cell watch to the worksheet.
|
|
1194
1538
|
#
|
|
@@ -1199,7 +1543,6 @@ module Xlsxrb
|
|
|
1199
1543
|
def cell_watch(ref)
|
|
1200
1544
|
@cell_watches << ref.to_s
|
|
1201
1545
|
end
|
|
1202
|
-
alias add_cell_watch cell_watch
|
|
1203
1546
|
|
|
1204
1547
|
# Adds an ignored error entry for the worksheet.
|
|
1205
1548
|
#
|
|
@@ -1208,57 +1551,57 @@ module Xlsxrb
|
|
|
1208
1551
|
# @return [void]
|
|
1209
1552
|
# @api public
|
|
1210
1553
|
#: (String sqref, ?eval_error: bool, ?two_digit_text_year: bool, ?number_stored_as_text: bool, ?formula: bool, ?formula_range: bool, ?unlocked_formula: bool, ?empty_cell_reference: bool, ?list_data_validation: bool, ?calculated_column: bool) -> void
|
|
1211
|
-
def
|
|
1554
|
+
def ignored_error(sqref, **opts)
|
|
1212
1555
|
@ignored_errors << { sqref: sqref.to_s }.merge(opts)
|
|
1213
1556
|
end
|
|
1214
|
-
alias add_ignored_error ignore_error
|
|
1215
1557
|
|
|
1216
1558
|
# Returns ignored error rules configured for this worksheet.
|
|
1217
1559
|
#
|
|
1218
|
-
# @return [Array<
|
|
1560
|
+
# @return [Array<Elements::IgnoredError>]
|
|
1219
1561
|
# @api public
|
|
1220
|
-
#: () -> Array[
|
|
1562
|
+
#: () -> Array[Elements::IgnoredError]
|
|
1221
1563
|
def ignored_errors
|
|
1222
|
-
@ignored_errors.
|
|
1223
|
-
end
|
|
1224
|
-
|
|
1225
|
-
# Gets
|
|
1226
|
-
#
|
|
1227
|
-
# @
|
|
1228
|
-
#
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
#
|
|
1237
|
-
#
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1564
|
+
@ignored_errors.map { |ie| ie.is_a?(Elements::IgnoredError) ? ie : Elements::IgnoredError.new(**ie) }.freeze
|
|
1565
|
+
end
|
|
1566
|
+
|
|
1567
|
+
# Gets phonetic (furigana) guide properties for the sheet.
|
|
1568
|
+
#
|
|
1569
|
+
# @return [Elements::PhoneticProperties, nil]
|
|
1570
|
+
# @api public
|
|
1571
|
+
#: () -> Elements::PhoneticProperties?
|
|
1572
|
+
def phonetic_properties
|
|
1573
|
+
return nil unless @phonetic_properties
|
|
1574
|
+
|
|
1575
|
+
@phonetic_properties.is_a?(Elements::PhoneticProperties) ? @phonetic_properties : Elements::PhoneticProperties.new(**@phonetic_properties)
|
|
1576
|
+
end
|
|
1577
|
+
|
|
1578
|
+
# Sets phonetic (furigana) guide properties for the sheet.
|
|
1579
|
+
#
|
|
1580
|
+
# @param spec [Hash, Integer, nil] Options hash or font ID integer.
|
|
1581
|
+
# @return [Hash[Symbol, untyped], Integer, nil]
|
|
1582
|
+
# @api public
|
|
1583
|
+
#: (Hash[Symbol, untyped] | Integer | nil spec) -> (Hash[Symbol, untyped] | Integer | nil)
|
|
1584
|
+
def phonetic_properties=(spec)
|
|
1585
|
+
if spec.nil?
|
|
1586
|
+
@phonetic_properties = nil
|
|
1242
1587
|
else
|
|
1243
1588
|
props = if spec.is_a?(Hash)
|
|
1244
|
-
spec.
|
|
1589
|
+
spec.dup
|
|
1245
1590
|
elsif spec.is_a?(Integer)
|
|
1246
|
-
{ font_id: spec
|
|
1591
|
+
{ font_id: spec }
|
|
1247
1592
|
else
|
|
1248
|
-
{
|
|
1593
|
+
{}
|
|
1249
1594
|
end
|
|
1250
|
-
props.compact!
|
|
1251
1595
|
@phonetic_properties = WorksheetBuilder.normalize_phonetic_properties(props)
|
|
1252
1596
|
end
|
|
1597
|
+
spec
|
|
1253
1598
|
end
|
|
1254
|
-
alias phonetic_properties= phonetic_properties
|
|
1255
|
-
alias phonetic_pr phonetic_properties
|
|
1256
|
-
alias phonetic_pr= phonetic_properties
|
|
1257
1599
|
|
|
1258
1600
|
# Normalizes phonetic properties to OOXML schema values.
|
|
1259
1601
|
#
|
|
1260
1602
|
# @param props [Hash, nil]
|
|
1261
1603
|
# @return [Hash[Symbol, untyped], nil]
|
|
1604
|
+
# @api private
|
|
1262
1605
|
#: (Hash[untyped, untyped]? props) -> Hash[Symbol, untyped]?
|
|
1263
1606
|
def self.normalize_phonetic_properties(props)
|
|
1264
1607
|
return nil if props.nil? || props.empty?
|
|
@@ -1288,43 +1631,54 @@ module Xlsxrb
|
|
|
1288
1631
|
res
|
|
1289
1632
|
end
|
|
1290
1633
|
|
|
1291
|
-
#
|
|
1634
|
+
# Gets the internal code name of the worksheet.
|
|
1292
1635
|
#
|
|
1293
|
-
# @param val [String, Symbol, nil] The code name.
|
|
1294
1636
|
# @return [String, nil]
|
|
1295
1637
|
# @api public
|
|
1296
|
-
#: (
|
|
1297
|
-
def code_name
|
|
1298
|
-
|
|
1638
|
+
#: () -> String?
|
|
1639
|
+
def code_name
|
|
1640
|
+
@sheet_properties[:code_name]
|
|
1641
|
+
end
|
|
1299
1642
|
|
|
1300
|
-
|
|
1643
|
+
# Sets the internal code name of the worksheet.
|
|
1644
|
+
#
|
|
1645
|
+
# @param val [String, Symbol, nil] The code name.
|
|
1646
|
+
# @return [String, nil]
|
|
1647
|
+
# @api public
|
|
1648
|
+
#: (String | Symbol | nil val) -> String?
|
|
1649
|
+
def code_name=(val)
|
|
1650
|
+
@sheet_properties[:code_name] = val&.to_s
|
|
1301
1651
|
end
|
|
1302
|
-
alias code_name= code_name
|
|
1303
1652
|
|
|
1304
|
-
#
|
|
1653
|
+
# Gets worksheet calculation properties (<sheetCalcPr>).
|
|
1305
1654
|
#
|
|
1306
|
-
# @
|
|
1307
|
-
#
|
|
1655
|
+
# @return [Elements::SheetCalcProperties, nil]
|
|
1656
|
+
# @api public
|
|
1657
|
+
#: () -> Elements::SheetCalcProperties?
|
|
1658
|
+
def sheet_calc_properties
|
|
1659
|
+
calc = @sheet_calc_pr || (@sheet_properties[:full_calc_on_load] ? { full_calc_on_load: true } : nil)
|
|
1660
|
+
return nil unless calc
|
|
1661
|
+
|
|
1662
|
+
calc.is_a?(Elements::SheetCalcProperties) ? calc : Elements::SheetCalcProperties.new(**calc)
|
|
1663
|
+
end
|
|
1664
|
+
|
|
1665
|
+
# Sets worksheet calculation properties (<sheetCalcPr>).
|
|
1308
1666
|
#
|
|
1309
1667
|
# @param spec [Hash, nil] Calculation properties hash.
|
|
1310
|
-
# @param full_calc_on_load [Boolean, nil] Whether to recalculate when loading.
|
|
1311
1668
|
# @return [Hash, nil]
|
|
1312
1669
|
# @api public
|
|
1313
|
-
#: (
|
|
1314
|
-
def
|
|
1315
|
-
if spec.nil?
|
|
1316
|
-
|
|
1670
|
+
#: (Hash[Symbol, untyped]? spec) -> Hash[Symbol, untyped]?
|
|
1671
|
+
def sheet_calc_properties=(spec)
|
|
1672
|
+
if spec.nil?
|
|
1673
|
+
@sheet_properties.delete(:full_calc_on_load)
|
|
1674
|
+
@sheet_calc_pr = nil
|
|
1675
|
+
else
|
|
1676
|
+
pr = spec.is_a?(Hash) ? spec.dup : {}
|
|
1677
|
+
@sheet_properties[:full_calc_on_load] = pr[:full_calc_on_load] unless pr[:full_calc_on_load].nil?
|
|
1678
|
+
@sheet_calc_pr = pr
|
|
1317
1679
|
end
|
|
1318
|
-
|
|
1319
|
-
pr = spec.is_a?(Hash) ? spec.dup : {}
|
|
1320
|
-
pr[:full_calc_on_load] = full_calc_on_load unless full_calc_on_load.nil?
|
|
1321
|
-
pr.merge!(opts) unless opts.empty?
|
|
1322
|
-
@sheet_properties[:full_calc_on_load] = pr[:full_calc_on_load] unless pr[:full_calc_on_load].nil?
|
|
1323
|
-
@sheet_calc_pr = pr
|
|
1680
|
+
spec
|
|
1324
1681
|
end
|
|
1325
|
-
alias sheet_calc_pr= sheet_calc_pr
|
|
1326
|
-
alias calc_pr sheet_calc_pr
|
|
1327
|
-
alias calc_pr= sheet_calc_pr
|
|
1328
1682
|
|
|
1329
1683
|
# Builds and returns the in-memory {Elements::Worksheet}.
|
|
1330
1684
|
#
|
|
@@ -1359,7 +1713,7 @@ module Xlsxrb
|
|
|
1359
1713
|
facade_meta[:sheet_format] = @sheet_format unless @sheet_format.empty?
|
|
1360
1714
|
facade_meta[:sheet_view] = @sheet_view unless @sheet_view.empty?
|
|
1361
1715
|
facade_meta[:row_breaks] = @row_breaks unless @row_breaks.empty?
|
|
1362
|
-
facade_meta[:
|
|
1716
|
+
facade_meta[:column_breaks] = @col_breaks unless @col_breaks.empty?
|
|
1363
1717
|
facade_meta[:protected_ranges] = @protected_ranges unless @protected_ranges.empty?
|
|
1364
1718
|
facade_meta[:cell_watches] = @cell_watches unless @cell_watches.empty?
|
|
1365
1719
|
facade_meta[:ignored_errors] = @ignored_errors unless @ignored_errors.empty?
|
|
@@ -1371,25 +1725,34 @@ module Xlsxrb
|
|
|
1371
1725
|
|
|
1372
1726
|
hl_hash = {}
|
|
1373
1727
|
@hyperlinks.each do |h|
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1728
|
+
if h.is_a?(Elements::Hyperlink)
|
|
1729
|
+
ref_val = h.ref if h.respond_to?(:ref)
|
|
1730
|
+
ref_val ||= h.cell if h.respond_to?(:cell)
|
|
1731
|
+
ref = ref_val.to_s.upcase
|
|
1732
|
+
hl_hash[ref] = h unless ref.empty?
|
|
1733
|
+
else
|
|
1734
|
+
ref = (h[:cell] || h[:ref]).to_s.upcase
|
|
1735
|
+
entry = {}
|
|
1736
|
+
entry[:url] = h[:url] if h[:url]
|
|
1737
|
+
entry[:display] = h[:display] if h[:display]
|
|
1738
|
+
entry[:tooltip] = h[:tooltip] if h[:tooltip]
|
|
1739
|
+
entry[:location] = h[:location] if h[:location]
|
|
1740
|
+
hl_hash[ref] = Elements::Hyperlink.new(**entry) unless entry.empty?
|
|
1741
|
+
end
|
|
1381
1742
|
end
|
|
1382
1743
|
|
|
1383
1744
|
cm_hash = {}
|
|
1384
1745
|
@comments.each do |c|
|
|
1385
|
-
|
|
1386
|
-
|
|
1746
|
+
obj = c.is_a?(Elements::Comment) ? c : Elements::Comment.new(**c)
|
|
1747
|
+
ref = (obj.respond_to?(:ref) ? obj.ref : obj[:ref]).to_s.upcase
|
|
1748
|
+
cm_hash[ref] = obj
|
|
1387
1749
|
end
|
|
1388
1750
|
|
|
1389
1751
|
tc_hash = {}
|
|
1390
1752
|
@threaded_comments.each do |c|
|
|
1391
|
-
|
|
1392
|
-
(
|
|
1753
|
+
obj = c.is_a?(Elements::ThreadedComment) ? c : Elements::ThreadedComment.new(**c)
|
|
1754
|
+
ref = (obj.respond_to?(:ref) ? obj.ref : obj[:ref]).to_s.upcase
|
|
1755
|
+
(tc_hash[ref] ||= []) << obj
|
|
1393
1756
|
end
|
|
1394
1757
|
|
|
1395
1758
|
rows = if hl_hash.empty? && cm_hash.empty? && tc_hash.empty?
|
|
@@ -1416,7 +1779,7 @@ module Xlsxrb
|
|
|
1416
1779
|
|
|
1417
1780
|
Elements::Worksheet.new(
|
|
1418
1781
|
name: @name, rows: rows, columns: @columns, charts: @charts,
|
|
1419
|
-
|
|
1782
|
+
conditional_formats: @conditional_formats,
|
|
1420
1783
|
data_validations: @data_validations,
|
|
1421
1784
|
unmapped_data: facade_meta.empty? ? {} : { facade: facade_meta },
|
|
1422
1785
|
state: @state,
|
|
@@ -1431,6 +1794,9 @@ module Xlsxrb
|
|
|
1431
1794
|
tables: @tables,
|
|
1432
1795
|
shapes: @shapes,
|
|
1433
1796
|
freeze_pane: @freeze_pane,
|
|
1797
|
+
split_pane: @split_pane,
|
|
1798
|
+
filter_columns: @filter_columns,
|
|
1799
|
+
sort_state: @sort_state,
|
|
1434
1800
|
page_setup: @page_setup,
|
|
1435
1801
|
page_margins: @page_margins,
|
|
1436
1802
|
header_footer: @header_footer,
|
|
@@ -1440,13 +1806,13 @@ module Xlsxrb
|
|
|
1440
1806
|
sheet_properties: @sheet_properties,
|
|
1441
1807
|
sheet_format: @sheet_format,
|
|
1442
1808
|
row_breaks: @row_breaks,
|
|
1443
|
-
|
|
1809
|
+
column_breaks: @col_breaks,
|
|
1444
1810
|
protected_ranges: @protected_ranges,
|
|
1445
1811
|
cell_watches: @cell_watches,
|
|
1446
1812
|
ignored_errors: @ignored_errors,
|
|
1447
1813
|
phonetic_properties: @phonetic_properties,
|
|
1448
1814
|
selection: @selection,
|
|
1449
|
-
|
|
1815
|
+
sheet_calc_properties: @sheet_calc_pr,
|
|
1450
1816
|
background_image: @background_image
|
|
1451
1817
|
)
|
|
1452
1818
|
end
|
|
@@ -1477,23 +1843,9 @@ module Xlsxrb
|
|
|
1477
1843
|
@options[:style] = style if style
|
|
1478
1844
|
end
|
|
1479
1845
|
|
|
1480
|
-
#: (
|
|
1481
|
-
def
|
|
1482
|
-
@options[
|
|
1483
|
-
end
|
|
1484
|
-
|
|
1485
|
-
#: (untyped key, untyped value) -> untyped
|
|
1486
|
-
def []=(key, value)
|
|
1487
|
-
@options[key.to_sym] = value
|
|
1488
|
-
end
|
|
1489
|
-
|
|
1490
|
-
#: (?String? val) -> String?
|
|
1491
|
-
def ref(val = nil)
|
|
1492
|
-
if val
|
|
1493
|
-
@options[:ref] = val.to_s
|
|
1494
|
-
else
|
|
1495
|
-
@options[:ref]
|
|
1496
|
-
end
|
|
1846
|
+
#: () -> String?
|
|
1847
|
+
def ref
|
|
1848
|
+
@options[:ref]
|
|
1497
1849
|
end
|
|
1498
1850
|
|
|
1499
1851
|
#: (String val) -> String
|
|
@@ -1501,14 +1853,20 @@ module Xlsxrb
|
|
|
1501
1853
|
@options[:ref] = val.to_s
|
|
1502
1854
|
end
|
|
1503
1855
|
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1856
|
+
# Returns column definitions for the table.
|
|
1857
|
+
#
|
|
1858
|
+
# @return [Array<Elements::TableColumn>]
|
|
1859
|
+
# @api public
|
|
1860
|
+
#: () -> Array[Elements::TableColumn]
|
|
1861
|
+
def columns
|
|
1862
|
+
(@options[:columns] || []).each_with_index.map do |c, idx|
|
|
1863
|
+
if c.is_a?(Elements::TableColumn)
|
|
1864
|
+
c
|
|
1865
|
+
elsif c.is_a?(Hash)
|
|
1866
|
+
Elements::TableColumn.new(id: idx + 1, **c)
|
|
1867
|
+
else
|
|
1868
|
+
Elements::TableColumn.new(id: idx + 1, name: c.to_s)
|
|
1869
|
+
end
|
|
1512
1870
|
end
|
|
1513
1871
|
end
|
|
1514
1872
|
|
|
@@ -1532,8 +1890,8 @@ module Xlsxrb
|
|
|
1532
1890
|
opts.merge(name: col.to_s)
|
|
1533
1891
|
end
|
|
1534
1892
|
(@options[:columns] ||= []) << col_spec
|
|
1893
|
+
nil
|
|
1535
1894
|
end
|
|
1536
|
-
alias add_column column
|
|
1537
1895
|
|
|
1538
1896
|
# Appends a calculated column with formula and options.
|
|
1539
1897
|
#
|
|
@@ -1546,13 +1904,9 @@ module Xlsxrb
|
|
|
1546
1904
|
column(name, formula: formula, **opts)
|
|
1547
1905
|
end
|
|
1548
1906
|
|
|
1549
|
-
#: (
|
|
1550
|
-
def name
|
|
1551
|
-
|
|
1552
|
-
@options[:name] = val.to_s
|
|
1553
|
-
else
|
|
1554
|
-
@options[:name]
|
|
1555
|
-
end
|
|
1907
|
+
#: () -> String?
|
|
1908
|
+
def name
|
|
1909
|
+
@options[:name]
|
|
1556
1910
|
end
|
|
1557
1911
|
|
|
1558
1912
|
#: (String val) -> String
|
|
@@ -1560,13 +1914,9 @@ module Xlsxrb
|
|
|
1560
1914
|
@options[:name] = val.to_s
|
|
1561
1915
|
end
|
|
1562
1916
|
|
|
1563
|
-
#: (
|
|
1564
|
-
def display_name
|
|
1565
|
-
|
|
1566
|
-
@options[:display_name] = val.to_s
|
|
1567
|
-
else
|
|
1568
|
-
@options[:display_name]
|
|
1569
|
-
end
|
|
1917
|
+
#: () -> String?
|
|
1918
|
+
def display_name
|
|
1919
|
+
@options[:display_name]
|
|
1570
1920
|
end
|
|
1571
1921
|
|
|
1572
1922
|
#: (String val) -> String
|
|
@@ -1574,13 +1924,9 @@ module Xlsxrb
|
|
|
1574
1924
|
@options[:display_name] = val.to_s
|
|
1575
1925
|
end
|
|
1576
1926
|
|
|
1577
|
-
#: (
|
|
1578
|
-
def style
|
|
1579
|
-
|
|
1580
|
-
@options[:style] = val.to_s
|
|
1581
|
-
else
|
|
1582
|
-
@options[:style]
|
|
1583
|
-
end
|
|
1927
|
+
#: () -> String?
|
|
1928
|
+
def style
|
|
1929
|
+
@options[:style]
|
|
1584
1930
|
end
|
|
1585
1931
|
|
|
1586
1932
|
#: (String val) -> String
|
|
@@ -1588,13 +1934,9 @@ module Xlsxrb
|
|
|
1588
1934
|
@options[:style] = val.to_s
|
|
1589
1935
|
end
|
|
1590
1936
|
|
|
1591
|
-
#: (
|
|
1592
|
-
def show_row_stripes
|
|
1593
|
-
|
|
1594
|
-
@options[:show_row_stripes]
|
|
1595
|
-
else
|
|
1596
|
-
@options[:show_row_stripes] = val ? true : false
|
|
1597
|
-
end
|
|
1937
|
+
#: () -> bool
|
|
1938
|
+
def show_row_stripes?
|
|
1939
|
+
@options[:show_row_stripes] ? true : false
|
|
1598
1940
|
end
|
|
1599
1941
|
|
|
1600
1942
|
#: (bool val) -> bool
|
|
@@ -1602,13 +1944,9 @@ module Xlsxrb
|
|
|
1602
1944
|
@options[:show_row_stripes] = val ? true : false
|
|
1603
1945
|
end
|
|
1604
1946
|
|
|
1605
|
-
#: (
|
|
1606
|
-
def show_column_stripes
|
|
1607
|
-
|
|
1608
|
-
@options[:show_column_stripes]
|
|
1609
|
-
else
|
|
1610
|
-
@options[:show_column_stripes] = val ? true : false
|
|
1611
|
-
end
|
|
1947
|
+
#: () -> bool
|
|
1948
|
+
def show_column_stripes?
|
|
1949
|
+
@options[:show_column_stripes] ? true : false
|
|
1612
1950
|
end
|
|
1613
1951
|
|
|
1614
1952
|
#: (bool val) -> bool
|
|
@@ -1616,13 +1954,9 @@ module Xlsxrb
|
|
|
1616
1954
|
@options[:show_column_stripes] = val ? true : false
|
|
1617
1955
|
end
|
|
1618
1956
|
|
|
1619
|
-
#: (
|
|
1620
|
-
def show_first_column
|
|
1621
|
-
|
|
1622
|
-
@options[:show_first_column]
|
|
1623
|
-
else
|
|
1624
|
-
@options[:show_first_column] = val ? true : false
|
|
1625
|
-
end
|
|
1957
|
+
#: () -> bool
|
|
1958
|
+
def show_first_column?
|
|
1959
|
+
@options[:show_first_column] ? true : false
|
|
1626
1960
|
end
|
|
1627
1961
|
|
|
1628
1962
|
#: (bool val) -> bool
|
|
@@ -1630,13 +1964,9 @@ module Xlsxrb
|
|
|
1630
1964
|
@options[:show_first_column] = val ? true : false
|
|
1631
1965
|
end
|
|
1632
1966
|
|
|
1633
|
-
#: (
|
|
1634
|
-
def show_last_column
|
|
1635
|
-
|
|
1636
|
-
@options[:show_last_column]
|
|
1637
|
-
else
|
|
1638
|
-
@options[:show_last_column] = val ? true : false
|
|
1639
|
-
end
|
|
1967
|
+
#: () -> bool
|
|
1968
|
+
def show_last_column?
|
|
1969
|
+
@options[:show_last_column] ? true : false
|
|
1640
1970
|
end
|
|
1641
1971
|
|
|
1642
1972
|
#: (bool val) -> bool
|
|
@@ -1644,43 +1974,38 @@ module Xlsxrb
|
|
|
1644
1974
|
@options[:show_last_column] = val ? true : false
|
|
1645
1975
|
end
|
|
1646
1976
|
|
|
1647
|
-
#: (
|
|
1648
|
-
def
|
|
1649
|
-
|
|
1650
|
-
@options[:totals_row_count] || @options[:total_row_count]
|
|
1651
|
-
else
|
|
1652
|
-
@options[:totals_row_count] = val.to_i
|
|
1653
|
-
end
|
|
1977
|
+
#: () -> Integer?
|
|
1978
|
+
def totals_row_count
|
|
1979
|
+
@options[:totals_row_count]
|
|
1654
1980
|
end
|
|
1655
|
-
alias totals_row_count total_row_count
|
|
1656
1981
|
|
|
1657
1982
|
#: (Integer val) -> Integer
|
|
1658
|
-
def
|
|
1983
|
+
def totals_row_count=(val)
|
|
1659
1984
|
@options[:totals_row_count] = val.to_i
|
|
1660
1985
|
end
|
|
1661
|
-
alias totals_row_count= total_row_count=
|
|
1662
1986
|
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1987
|
+
# Returns whether the table has a totals row.
|
|
1988
|
+
#
|
|
1989
|
+
# @return [Boolean]
|
|
1990
|
+
#: () -> bool
|
|
1991
|
+
def totals_row?
|
|
1992
|
+
rc = @options[:totals_row_count]
|
|
1993
|
+
if rc
|
|
1994
|
+
rc.positive?
|
|
1668
1995
|
else
|
|
1669
|
-
@options[:
|
|
1670
|
-
val ? true : false
|
|
1996
|
+
@options[:totals_row] ? true : false
|
|
1671
1997
|
end
|
|
1672
1998
|
end
|
|
1673
|
-
alias total_row= total_row
|
|
1674
|
-
alias totals_row total_row
|
|
1675
|
-
alias totals_row= total_row
|
|
1676
1999
|
|
|
1677
|
-
#: (
|
|
1678
|
-
def
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
2000
|
+
#: (bool val) -> bool
|
|
2001
|
+
def totals_row=(val)
|
|
2002
|
+
@options[:totals_row_count] = val ? 1 : 0
|
|
2003
|
+
val
|
|
2004
|
+
end
|
|
2005
|
+
|
|
2006
|
+
#: () -> bool
|
|
2007
|
+
def auto_filter?
|
|
2008
|
+
@options[:auto_filter] != false
|
|
1684
2009
|
end
|
|
1685
2010
|
|
|
1686
2011
|
#: (bool val) -> bool
|
|
@@ -1706,71 +2031,39 @@ module Xlsxrb
|
|
|
1706
2031
|
@options[:sqref] = sqref if sqref
|
|
1707
2032
|
end
|
|
1708
2033
|
|
|
1709
|
-
#: (
|
|
1710
|
-
def
|
|
1711
|
-
@options[
|
|
1712
|
-
end
|
|
1713
|
-
|
|
1714
|
-
#: (untyped key, untyped value) -> untyped
|
|
1715
|
-
def []=(key, value)
|
|
1716
|
-
@options[key.to_sym] = value
|
|
1717
|
-
end
|
|
1718
|
-
|
|
1719
|
-
#: (?String? val) -> String?
|
|
1720
|
-
def sqref(val = nil)
|
|
1721
|
-
if val
|
|
1722
|
-
@options[:sqref] = val.to_s
|
|
1723
|
-
else
|
|
1724
|
-
@options[:sqref]
|
|
1725
|
-
end
|
|
2034
|
+
#: () -> String?
|
|
2035
|
+
def sqref
|
|
2036
|
+
@options[:sqref]
|
|
1726
2037
|
end
|
|
1727
2038
|
|
|
1728
2039
|
#: (String val) -> String
|
|
1729
2040
|
def sqref=(val)
|
|
1730
2041
|
@options[:sqref] = val.to_s
|
|
1731
2042
|
end
|
|
1732
|
-
alias range sqref
|
|
1733
|
-
alias range= sqref=
|
|
1734
2043
|
|
|
1735
|
-
#: (
|
|
1736
|
-
def columns
|
|
1737
|
-
|
|
1738
|
-
@options[:columns] = val
|
|
1739
|
-
else
|
|
1740
|
-
@options[:columns]
|
|
1741
|
-
end
|
|
2044
|
+
#: () -> untyped
|
|
2045
|
+
def columns
|
|
2046
|
+
@options[:columns]
|
|
1742
2047
|
end
|
|
1743
2048
|
|
|
1744
2049
|
#: (untyped val) -> untyped
|
|
1745
2050
|
def columns=(val)
|
|
1746
2051
|
@options[:columns] = val
|
|
1747
2052
|
end
|
|
1748
|
-
alias col columns
|
|
1749
|
-
alias col= columns=
|
|
1750
2053
|
|
|
1751
|
-
#: (
|
|
1752
|
-
def rows
|
|
1753
|
-
|
|
1754
|
-
@options[:rows] = val
|
|
1755
|
-
else
|
|
1756
|
-
@options[:rows]
|
|
1757
|
-
end
|
|
2054
|
+
#: () -> untyped
|
|
2055
|
+
def rows
|
|
2056
|
+
@options[:rows]
|
|
1758
2057
|
end
|
|
1759
2058
|
|
|
1760
2059
|
#: (untyped val) -> untyped
|
|
1761
2060
|
def rows=(val)
|
|
1762
2061
|
@options[:rows] = val
|
|
1763
2062
|
end
|
|
1764
|
-
alias row rows
|
|
1765
|
-
alias row= rows=
|
|
1766
2063
|
|
|
1767
|
-
#: (
|
|
1768
|
-
def except_rows
|
|
1769
|
-
|
|
1770
|
-
@options[:except_rows] = val
|
|
1771
|
-
else
|
|
1772
|
-
@options[:except_rows]
|
|
1773
|
-
end
|
|
2064
|
+
#: () -> untyped
|
|
2065
|
+
def except_rows
|
|
2066
|
+
@options[:except_rows]
|
|
1774
2067
|
end
|
|
1775
2068
|
|
|
1776
2069
|
#: (untyped val) -> untyped
|
|
@@ -1778,27 +2071,26 @@ module Xlsxrb
|
|
|
1778
2071
|
@options[:except_rows] = val
|
|
1779
2072
|
end
|
|
1780
2073
|
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
2074
|
+
# Sets or gets the list validation choices.
|
|
2075
|
+
#
|
|
2076
|
+
# @example
|
|
2077
|
+
# b.list = ["Option1", "Option2"]
|
|
2078
|
+
#
|
|
2079
|
+
# @return [Array<Object>, nil]
|
|
2080
|
+
# @api public
|
|
2081
|
+
#: () -> untyped
|
|
2082
|
+
def list
|
|
2083
|
+
@options[:list]
|
|
1788
2084
|
end
|
|
1789
2085
|
|
|
1790
2086
|
#: (Array[untyped] val) -> untyped
|
|
1791
|
-
def
|
|
1792
|
-
@options[:
|
|
2087
|
+
def list=(val)
|
|
2088
|
+
@options[:list] = val
|
|
1793
2089
|
end
|
|
1794
2090
|
|
|
1795
|
-
#: (
|
|
1796
|
-
def type
|
|
1797
|
-
|
|
1798
|
-
@options[:type] = val
|
|
1799
|
-
else
|
|
1800
|
-
@options[:type]
|
|
1801
|
-
end
|
|
2091
|
+
#: () -> untyped
|
|
2092
|
+
def type
|
|
2093
|
+
@options[:type]
|
|
1802
2094
|
end
|
|
1803
2095
|
|
|
1804
2096
|
#: (untyped val) -> untyped
|
|
@@ -1806,13 +2098,9 @@ module Xlsxrb
|
|
|
1806
2098
|
@options[:type] = val
|
|
1807
2099
|
end
|
|
1808
2100
|
|
|
1809
|
-
#: (
|
|
1810
|
-
def operator
|
|
1811
|
-
|
|
1812
|
-
@options[:operator] = val
|
|
1813
|
-
else
|
|
1814
|
-
@options[:operator]
|
|
1815
|
-
end
|
|
2101
|
+
#: () -> untyped
|
|
2102
|
+
def operator
|
|
2103
|
+
@options[:operator]
|
|
1816
2104
|
end
|
|
1817
2105
|
|
|
1818
2106
|
#: (untyped val) -> untyped
|
|
@@ -1820,13 +2108,9 @@ module Xlsxrb
|
|
|
1820
2108
|
@options[:operator] = val
|
|
1821
2109
|
end
|
|
1822
2110
|
|
|
1823
|
-
#: (
|
|
1824
|
-
def formula1
|
|
1825
|
-
|
|
1826
|
-
@options[:formula1] = val
|
|
1827
|
-
else
|
|
1828
|
-
@options[:formula1]
|
|
1829
|
-
end
|
|
2111
|
+
#: () -> untyped
|
|
2112
|
+
def formula1
|
|
2113
|
+
@options[:formula1]
|
|
1830
2114
|
end
|
|
1831
2115
|
|
|
1832
2116
|
#: (untyped val) -> untyped
|
|
@@ -1834,13 +2118,9 @@ module Xlsxrb
|
|
|
1834
2118
|
@options[:formula1] = val
|
|
1835
2119
|
end
|
|
1836
2120
|
|
|
1837
|
-
#: (
|
|
1838
|
-
def formula2
|
|
1839
|
-
|
|
1840
|
-
@options[:formula2] = val
|
|
1841
|
-
else
|
|
1842
|
-
@options[:formula2]
|
|
1843
|
-
end
|
|
2121
|
+
#: () -> untyped
|
|
2122
|
+
def formula2
|
|
2123
|
+
@options[:formula2]
|
|
1844
2124
|
end
|
|
1845
2125
|
|
|
1846
2126
|
#: (untyped val) -> untyped
|
|
@@ -1848,13 +2128,9 @@ module Xlsxrb
|
|
|
1848
2128
|
@options[:formula2] = val
|
|
1849
2129
|
end
|
|
1850
2130
|
|
|
1851
|
-
#: (
|
|
1852
|
-
def allow_blank
|
|
1853
|
-
|
|
1854
|
-
@options[:allow_blank]
|
|
1855
|
-
else
|
|
1856
|
-
@options[:allow_blank] = val ? true : false
|
|
1857
|
-
end
|
|
2131
|
+
#: () -> bool
|
|
2132
|
+
def allow_blank?
|
|
2133
|
+
@options[:allow_blank] ? true : false
|
|
1858
2134
|
end
|
|
1859
2135
|
|
|
1860
2136
|
#: (bool val) -> bool
|
|
@@ -1862,13 +2138,9 @@ module Xlsxrb
|
|
|
1862
2138
|
@options[:allow_blank] = val ? true : false
|
|
1863
2139
|
end
|
|
1864
2140
|
|
|
1865
|
-
#: (
|
|
1866
|
-
def show_input_message
|
|
1867
|
-
|
|
1868
|
-
@options[:show_input_message]
|
|
1869
|
-
else
|
|
1870
|
-
@options[:show_input_message] = val ? true : false
|
|
1871
|
-
end
|
|
2141
|
+
#: () -> bool
|
|
2142
|
+
def show_input_message?
|
|
2143
|
+
@options[:show_input_message] ? true : false
|
|
1872
2144
|
end
|
|
1873
2145
|
|
|
1874
2146
|
#: (bool val) -> bool
|
|
@@ -1876,13 +2148,9 @@ module Xlsxrb
|
|
|
1876
2148
|
@options[:show_input_message] = val ? true : false
|
|
1877
2149
|
end
|
|
1878
2150
|
|
|
1879
|
-
#: (
|
|
1880
|
-
def show_error_message
|
|
1881
|
-
|
|
1882
|
-
@options[:show_error_message]
|
|
1883
|
-
else
|
|
1884
|
-
@options[:show_error_message] = val ? true : false
|
|
1885
|
-
end
|
|
2151
|
+
#: () -> bool
|
|
2152
|
+
def show_error_message?
|
|
2153
|
+
@options[:show_error_message] ? true : false
|
|
1886
2154
|
end
|
|
1887
2155
|
|
|
1888
2156
|
#: (bool val) -> bool
|
|
@@ -1890,13 +2158,9 @@ module Xlsxrb
|
|
|
1890
2158
|
@options[:show_error_message] = val ? true : false
|
|
1891
2159
|
end
|
|
1892
2160
|
|
|
1893
|
-
#: (
|
|
1894
|
-
def error_title
|
|
1895
|
-
|
|
1896
|
-
@options[:error_title] = val.to_s
|
|
1897
|
-
else
|
|
1898
|
-
@options[:error_title]
|
|
1899
|
-
end
|
|
2161
|
+
#: () -> String?
|
|
2162
|
+
def error_title
|
|
2163
|
+
@options[:error_title]
|
|
1900
2164
|
end
|
|
1901
2165
|
|
|
1902
2166
|
#: (String val) -> String
|
|
@@ -1904,29 +2168,19 @@ module Xlsxrb
|
|
|
1904
2168
|
@options[:error_title] = val.to_s
|
|
1905
2169
|
end
|
|
1906
2170
|
|
|
1907
|
-
#: (
|
|
1908
|
-
def error_message
|
|
1909
|
-
|
|
1910
|
-
@options[:error] = val.to_s
|
|
1911
|
-
else
|
|
1912
|
-
@options[:error]
|
|
1913
|
-
end
|
|
2171
|
+
#: () -> String?
|
|
2172
|
+
def error_message
|
|
2173
|
+
@options[:error]
|
|
1914
2174
|
end
|
|
1915
2175
|
|
|
1916
2176
|
#: (String val) -> String
|
|
1917
2177
|
def error_message=(val)
|
|
1918
2178
|
@options[:error] = val.to_s
|
|
1919
2179
|
end
|
|
1920
|
-
alias error error_message
|
|
1921
|
-
alias error= error_message=
|
|
1922
2180
|
|
|
1923
|
-
#: (
|
|
1924
|
-
def prompt_title
|
|
1925
|
-
|
|
1926
|
-
@options[:prompt_title] = val.to_s
|
|
1927
|
-
else
|
|
1928
|
-
@options[:prompt_title]
|
|
1929
|
-
end
|
|
2181
|
+
#: () -> String?
|
|
2182
|
+
def prompt_title
|
|
2183
|
+
@options[:prompt_title]
|
|
1930
2184
|
end
|
|
1931
2185
|
|
|
1932
2186
|
#: (String val) -> String
|
|
@@ -1934,29 +2188,19 @@ module Xlsxrb
|
|
|
1934
2188
|
@options[:prompt_title] = val.to_s
|
|
1935
2189
|
end
|
|
1936
2190
|
|
|
1937
|
-
#: (
|
|
1938
|
-
def prompt_message
|
|
1939
|
-
|
|
1940
|
-
@options[:prompt] = val.to_s
|
|
1941
|
-
else
|
|
1942
|
-
@options[:prompt]
|
|
1943
|
-
end
|
|
2191
|
+
#: () -> String?
|
|
2192
|
+
def prompt_message
|
|
2193
|
+
@options[:prompt]
|
|
1944
2194
|
end
|
|
1945
2195
|
|
|
1946
2196
|
#: (String val) -> String
|
|
1947
2197
|
def prompt_message=(val)
|
|
1948
2198
|
@options[:prompt] = val.to_s
|
|
1949
2199
|
end
|
|
1950
|
-
alias prompt prompt_message
|
|
1951
|
-
alias prompt= prompt_message=
|
|
1952
2200
|
|
|
1953
|
-
#: (
|
|
1954
|
-
def error_style
|
|
1955
|
-
|
|
1956
|
-
@options[:error_style] = val
|
|
1957
|
-
else
|
|
1958
|
-
@options[:error_style]
|
|
1959
|
-
end
|
|
2201
|
+
#: () -> untyped
|
|
2202
|
+
def error_style
|
|
2203
|
+
@options[:error_style]
|
|
1960
2204
|
end
|
|
1961
2205
|
|
|
1962
2206
|
#: (untyped val) -> untyped
|
|
@@ -1982,71 +2226,39 @@ module Xlsxrb
|
|
|
1982
2226
|
@options[:sqref] = sqref if sqref
|
|
1983
2227
|
end
|
|
1984
2228
|
|
|
1985
|
-
#: (
|
|
1986
|
-
def
|
|
1987
|
-
@options[
|
|
1988
|
-
end
|
|
1989
|
-
|
|
1990
|
-
#: (untyped key, untyped value) -> untyped
|
|
1991
|
-
def []=(key, value)
|
|
1992
|
-
@options[key.to_sym] = value
|
|
1993
|
-
end
|
|
1994
|
-
|
|
1995
|
-
#: (?String? val) -> String?
|
|
1996
|
-
def sqref(val = nil)
|
|
1997
|
-
if val
|
|
1998
|
-
@options[:sqref] = val.to_s
|
|
1999
|
-
else
|
|
2000
|
-
@options[:sqref]
|
|
2001
|
-
end
|
|
2229
|
+
#: () -> String?
|
|
2230
|
+
def sqref
|
|
2231
|
+
@options[:sqref]
|
|
2002
2232
|
end
|
|
2003
2233
|
|
|
2004
2234
|
#: (String val) -> String
|
|
2005
2235
|
def sqref=(val)
|
|
2006
2236
|
@options[:sqref] = val.to_s
|
|
2007
2237
|
end
|
|
2008
|
-
alias range sqref
|
|
2009
|
-
alias range= sqref=
|
|
2010
2238
|
|
|
2011
|
-
#: (
|
|
2012
|
-
def columns
|
|
2013
|
-
|
|
2014
|
-
@options[:columns] = val
|
|
2015
|
-
else
|
|
2016
|
-
@options[:columns]
|
|
2017
|
-
end
|
|
2239
|
+
#: () -> untyped
|
|
2240
|
+
def columns
|
|
2241
|
+
@options[:columns]
|
|
2018
2242
|
end
|
|
2019
2243
|
|
|
2020
2244
|
#: (untyped val) -> untyped
|
|
2021
2245
|
def columns=(val)
|
|
2022
2246
|
@options[:columns] = val
|
|
2023
2247
|
end
|
|
2024
|
-
alias col columns
|
|
2025
|
-
alias col= columns=
|
|
2026
2248
|
|
|
2027
|
-
#: (
|
|
2028
|
-
def rows
|
|
2029
|
-
|
|
2030
|
-
@options[:rows] = val
|
|
2031
|
-
else
|
|
2032
|
-
@options[:rows]
|
|
2033
|
-
end
|
|
2249
|
+
#: () -> untyped
|
|
2250
|
+
def rows
|
|
2251
|
+
@options[:rows]
|
|
2034
2252
|
end
|
|
2035
2253
|
|
|
2036
2254
|
#: (untyped val) -> untyped
|
|
2037
2255
|
def rows=(val)
|
|
2038
2256
|
@options[:rows] = val
|
|
2039
2257
|
end
|
|
2040
|
-
alias row rows
|
|
2041
|
-
alias row= rows=
|
|
2042
2258
|
|
|
2043
|
-
#: (
|
|
2044
|
-
def except_rows
|
|
2045
|
-
|
|
2046
|
-
@options[:except_rows] = val
|
|
2047
|
-
else
|
|
2048
|
-
@options[:except_rows]
|
|
2049
|
-
end
|
|
2259
|
+
#: () -> untyped
|
|
2260
|
+
def except_rows
|
|
2261
|
+
@options[:except_rows]
|
|
2050
2262
|
end
|
|
2051
2263
|
|
|
2052
2264
|
#: (untyped val) -> untyped
|
|
@@ -2054,13 +2266,9 @@ module Xlsxrb
|
|
|
2054
2266
|
@options[:except_rows] = val
|
|
2055
2267
|
end
|
|
2056
2268
|
|
|
2057
|
-
#: (
|
|
2058
|
-
def type
|
|
2059
|
-
|
|
2060
|
-
@options[:type] = val
|
|
2061
|
-
else
|
|
2062
|
-
@options[:type]
|
|
2063
|
-
end
|
|
2269
|
+
#: () -> untyped
|
|
2270
|
+
def type
|
|
2271
|
+
@options[:type]
|
|
2064
2272
|
end
|
|
2065
2273
|
|
|
2066
2274
|
#: (untyped val) -> untyped
|
|
@@ -2068,13 +2276,9 @@ module Xlsxrb
|
|
|
2068
2276
|
@options[:type] = val
|
|
2069
2277
|
end
|
|
2070
2278
|
|
|
2071
|
-
#: (
|
|
2072
|
-
def operator
|
|
2073
|
-
|
|
2074
|
-
@options[:operator] = val
|
|
2075
|
-
else
|
|
2076
|
-
@options[:operator]
|
|
2077
|
-
end
|
|
2279
|
+
#: () -> untyped
|
|
2280
|
+
def operator
|
|
2281
|
+
@options[:operator]
|
|
2078
2282
|
end
|
|
2079
2283
|
|
|
2080
2284
|
#: (untyped val) -> untyped
|
|
@@ -2082,13 +2286,9 @@ module Xlsxrb
|
|
|
2082
2286
|
@options[:operator] = val
|
|
2083
2287
|
end
|
|
2084
2288
|
|
|
2085
|
-
#: (
|
|
2086
|
-
def formula
|
|
2087
|
-
|
|
2088
|
-
@options[:formula] = val
|
|
2089
|
-
else
|
|
2090
|
-
@options[:formula]
|
|
2091
|
-
end
|
|
2289
|
+
#: () -> untyped
|
|
2290
|
+
def formula
|
|
2291
|
+
@options[:formula]
|
|
2092
2292
|
end
|
|
2093
2293
|
|
|
2094
2294
|
#: (untyped val) -> untyped
|
|
@@ -2096,29 +2296,9 @@ module Xlsxrb
|
|
|
2096
2296
|
@options[:formula] = val
|
|
2097
2297
|
end
|
|
2098
2298
|
|
|
2099
|
-
#: (
|
|
2100
|
-
def
|
|
2101
|
-
|
|
2102
|
-
@options[:formulas]
|
|
2103
|
-
elsif vals.size == 1 && vals.first.is_a?(Array)
|
|
2104
|
-
@options[:formulas] = vals.first
|
|
2105
|
-
else
|
|
2106
|
-
@options[:formulas] = vals
|
|
2107
|
-
end
|
|
2108
|
-
end
|
|
2109
|
-
|
|
2110
|
-
#: (untyped vals) -> untyped
|
|
2111
|
-
def formulas=(vals)
|
|
2112
|
-
@options[:formulas] = vals.is_a?(Array) ? vals : [vals]
|
|
2113
|
-
end
|
|
2114
|
-
|
|
2115
|
-
#: (?untyped val) -> untyped
|
|
2116
|
-
def font(val = nil)
|
|
2117
|
-
if val
|
|
2118
|
-
@options[:font] = val
|
|
2119
|
-
else
|
|
2120
|
-
@options[:font]
|
|
2121
|
-
end
|
|
2299
|
+
#: () -> untyped
|
|
2300
|
+
def font
|
|
2301
|
+
@options[:font]
|
|
2122
2302
|
end
|
|
2123
2303
|
|
|
2124
2304
|
#: (untyped val) -> untyped
|
|
@@ -2126,13 +2306,9 @@ module Xlsxrb
|
|
|
2126
2306
|
@options[:font] = val
|
|
2127
2307
|
end
|
|
2128
2308
|
|
|
2129
|
-
#: (
|
|
2130
|
-
def fill
|
|
2131
|
-
|
|
2132
|
-
@options[:fill] = val
|
|
2133
|
-
else
|
|
2134
|
-
@options[:fill]
|
|
2135
|
-
end
|
|
2309
|
+
#: () -> untyped
|
|
2310
|
+
def fill
|
|
2311
|
+
@options[:fill]
|
|
2136
2312
|
end
|
|
2137
2313
|
|
|
2138
2314
|
#: (untyped val) -> untyped
|
|
@@ -2140,13 +2316,9 @@ module Xlsxrb
|
|
|
2140
2316
|
@options[:fill] = val
|
|
2141
2317
|
end
|
|
2142
2318
|
|
|
2143
|
-
#: (
|
|
2144
|
-
def fill_color
|
|
2145
|
-
|
|
2146
|
-
@options[:fill_color] = val
|
|
2147
|
-
else
|
|
2148
|
-
@options[:fill_color]
|
|
2149
|
-
end
|
|
2319
|
+
#: () -> untyped
|
|
2320
|
+
def fill_color
|
|
2321
|
+
@options[:fill_color]
|
|
2150
2322
|
end
|
|
2151
2323
|
|
|
2152
2324
|
#: (untyped val) -> untyped
|
|
@@ -2154,13 +2326,9 @@ module Xlsxrb
|
|
|
2154
2326
|
@options[:fill_color] = val
|
|
2155
2327
|
end
|
|
2156
2328
|
|
|
2157
|
-
#: (
|
|
2158
|
-
def font_color
|
|
2159
|
-
|
|
2160
|
-
@options[:font_color] = val
|
|
2161
|
-
else
|
|
2162
|
-
@options[:font_color]
|
|
2163
|
-
end
|
|
2329
|
+
#: () -> untyped
|
|
2330
|
+
def font_color
|
|
2331
|
+
@options[:font_color]
|
|
2164
2332
|
end
|
|
2165
2333
|
|
|
2166
2334
|
#: (untyped val) -> untyped
|
|
@@ -2168,13 +2336,9 @@ module Xlsxrb
|
|
|
2168
2336
|
@options[:font_color] = val
|
|
2169
2337
|
end
|
|
2170
2338
|
|
|
2171
|
-
#: (
|
|
2172
|
-
def bold
|
|
2173
|
-
|
|
2174
|
-
@options[:bold]
|
|
2175
|
-
else
|
|
2176
|
-
@options[:bold] = val ? true : false
|
|
2177
|
-
end
|
|
2339
|
+
#: () -> bool
|
|
2340
|
+
def bold?
|
|
2341
|
+
@options[:bold] ? true : false
|
|
2178
2342
|
end
|
|
2179
2343
|
|
|
2180
2344
|
#: (bool val) -> bool
|
|
@@ -2182,13 +2346,9 @@ module Xlsxrb
|
|
|
2182
2346
|
@options[:bold] = val ? true : false
|
|
2183
2347
|
end
|
|
2184
2348
|
|
|
2185
|
-
#: (
|
|
2186
|
-
def italic
|
|
2187
|
-
|
|
2188
|
-
@options[:italic]
|
|
2189
|
-
else
|
|
2190
|
-
@options[:italic] = val ? true : false
|
|
2191
|
-
end
|
|
2349
|
+
#: () -> bool
|
|
2350
|
+
def italic?
|
|
2351
|
+
@options[:italic] ? true : false
|
|
2192
2352
|
end
|
|
2193
2353
|
|
|
2194
2354
|
#: (bool val) -> bool
|
|
@@ -2196,13 +2356,9 @@ module Xlsxrb
|
|
|
2196
2356
|
@options[:italic] = val ? true : false
|
|
2197
2357
|
end
|
|
2198
2358
|
|
|
2199
|
-
#: (
|
|
2200
|
-
def underline
|
|
2201
|
-
|
|
2202
|
-
@options[:underline]
|
|
2203
|
-
else
|
|
2204
|
-
@options[:underline] = val
|
|
2205
|
-
end
|
|
2359
|
+
#: () -> untyped
|
|
2360
|
+
def underline
|
|
2361
|
+
@options[:underline]
|
|
2206
2362
|
end
|
|
2207
2363
|
|
|
2208
2364
|
#: (untyped val) -> untyped
|
|
@@ -2210,29 +2366,29 @@ module Xlsxrb
|
|
|
2210
2366
|
@options[:underline] = val
|
|
2211
2367
|
end
|
|
2212
2368
|
|
|
2213
|
-
#: (
|
|
2214
|
-
def
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2369
|
+
#: () -> String?
|
|
2370
|
+
def font_name
|
|
2371
|
+
@options[:font_name]
|
|
2372
|
+
end
|
|
2373
|
+
|
|
2374
|
+
#: (String val) -> String
|
|
2375
|
+
def font_name=(val)
|
|
2376
|
+
@options[:font_name] = val.to_s
|
|
2377
|
+
end
|
|
2378
|
+
|
|
2379
|
+
#: () -> untyped
|
|
2380
|
+
def font_size
|
|
2381
|
+
@options[:font_size]
|
|
2220
2382
|
end
|
|
2221
2383
|
|
|
2222
2384
|
#: (untyped val) -> untyped
|
|
2223
|
-
def
|
|
2224
|
-
@options[:
|
|
2385
|
+
def font_size=(val)
|
|
2386
|
+
@options[:font_size] = val
|
|
2225
2387
|
end
|
|
2226
|
-
alias sz size
|
|
2227
|
-
alias sz= size=
|
|
2228
2388
|
|
|
2229
|
-
#: (
|
|
2230
|
-
def stop_if_true
|
|
2231
|
-
|
|
2232
|
-
@options[:stop_if_true]
|
|
2233
|
-
else
|
|
2234
|
-
@options[:stop_if_true] = val ? true : false
|
|
2235
|
-
end
|
|
2389
|
+
#: () -> bool
|
|
2390
|
+
def stop_if_true?
|
|
2391
|
+
@options[:stop_if_true] ? true : false
|
|
2236
2392
|
end
|
|
2237
2393
|
|
|
2238
2394
|
#: (bool val) -> bool
|
|
@@ -2240,13 +2396,9 @@ module Xlsxrb
|
|
|
2240
2396
|
@options[:stop_if_true] = val ? true : false
|
|
2241
2397
|
end
|
|
2242
2398
|
|
|
2243
|
-
#: (
|
|
2244
|
-
def priority
|
|
2245
|
-
|
|
2246
|
-
@options[:priority] = val.to_i
|
|
2247
|
-
else
|
|
2248
|
-
@options[:priority]
|
|
2249
|
-
end
|
|
2399
|
+
#: () -> Integer?
|
|
2400
|
+
def priority
|
|
2401
|
+
@options[:priority]
|
|
2250
2402
|
end
|
|
2251
2403
|
|
|
2252
2404
|
#: (Integer val) -> Integer
|
|
@@ -2254,13 +2406,9 @@ module Xlsxrb
|
|
|
2254
2406
|
@options[:priority] = val.to_i
|
|
2255
2407
|
end
|
|
2256
2408
|
|
|
2257
|
-
#: (
|
|
2258
|
-
def above_average
|
|
2259
|
-
|
|
2260
|
-
@options[:above_average]
|
|
2261
|
-
else
|
|
2262
|
-
@options[:above_average] = val ? true : false
|
|
2263
|
-
end
|
|
2409
|
+
#: () -> bool
|
|
2410
|
+
def above_average?
|
|
2411
|
+
@options[:above_average] ? true : false
|
|
2264
2412
|
end
|
|
2265
2413
|
|
|
2266
2414
|
#: (bool val) -> bool
|
|
@@ -2268,13 +2416,9 @@ module Xlsxrb
|
|
|
2268
2416
|
@options[:above_average] = val ? true : false
|
|
2269
2417
|
end
|
|
2270
2418
|
|
|
2271
|
-
#: (
|
|
2272
|
-
def equal_average
|
|
2273
|
-
|
|
2274
|
-
@options[:equal_average]
|
|
2275
|
-
else
|
|
2276
|
-
@options[:equal_average] = val ? true : false
|
|
2277
|
-
end
|
|
2419
|
+
#: () -> bool
|
|
2420
|
+
def equal_average?
|
|
2421
|
+
@options[:equal_average] ? true : false
|
|
2278
2422
|
end
|
|
2279
2423
|
|
|
2280
2424
|
#: (bool val) -> bool
|
|
@@ -2282,13 +2426,9 @@ module Xlsxrb
|
|
|
2282
2426
|
@options[:equal_average] = val ? true : false
|
|
2283
2427
|
end
|
|
2284
2428
|
|
|
2285
|
-
#: (
|
|
2286
|
-
def std_dev
|
|
2287
|
-
|
|
2288
|
-
@options[:std_dev] = val.to_i
|
|
2289
|
-
else
|
|
2290
|
-
@options[:std_dev]
|
|
2291
|
-
end
|
|
2429
|
+
#: () -> Integer?
|
|
2430
|
+
def std_dev
|
|
2431
|
+
@options[:std_dev]
|
|
2292
2432
|
end
|
|
2293
2433
|
|
|
2294
2434
|
#: (Integer val) -> Integer
|
|
@@ -2296,13 +2436,9 @@ module Xlsxrb
|
|
|
2296
2436
|
@options[:std_dev] = val.to_i
|
|
2297
2437
|
end
|
|
2298
2438
|
|
|
2299
|
-
#: (
|
|
2300
|
-
def rank
|
|
2301
|
-
|
|
2302
|
-
@options[:rank] = val.to_i
|
|
2303
|
-
else
|
|
2304
|
-
@options[:rank]
|
|
2305
|
-
end
|
|
2439
|
+
#: () -> Integer?
|
|
2440
|
+
def rank
|
|
2441
|
+
@options[:rank]
|
|
2306
2442
|
end
|
|
2307
2443
|
|
|
2308
2444
|
#: (Integer val) -> Integer
|
|
@@ -2310,13 +2446,9 @@ module Xlsxrb
|
|
|
2310
2446
|
@options[:rank] = val.to_i
|
|
2311
2447
|
end
|
|
2312
2448
|
|
|
2313
|
-
#: (
|
|
2314
|
-
def percent
|
|
2315
|
-
|
|
2316
|
-
@options[:percent]
|
|
2317
|
-
else
|
|
2318
|
-
@options[:percent] = val ? true : false
|
|
2319
|
-
end
|
|
2449
|
+
#: () -> bool
|
|
2450
|
+
def percent?
|
|
2451
|
+
@options[:percent] ? true : false
|
|
2320
2452
|
end
|
|
2321
2453
|
|
|
2322
2454
|
#: (bool val) -> bool
|
|
@@ -2324,13 +2456,9 @@ module Xlsxrb
|
|
|
2324
2456
|
@options[:percent] = val ? true : false
|
|
2325
2457
|
end
|
|
2326
2458
|
|
|
2327
|
-
#: (
|
|
2328
|
-
def bottom
|
|
2329
|
-
|
|
2330
|
-
@options[:bottom]
|
|
2331
|
-
else
|
|
2332
|
-
@options[:bottom] = val ? true : false
|
|
2333
|
-
end
|
|
2459
|
+
#: () -> bool
|
|
2460
|
+
def bottom?
|
|
2461
|
+
@options[:bottom] ? true : false
|
|
2334
2462
|
end
|
|
2335
2463
|
|
|
2336
2464
|
#: (bool val) -> bool
|
|
@@ -2338,13 +2466,9 @@ module Xlsxrb
|
|
|
2338
2466
|
@options[:bottom] = val ? true : false
|
|
2339
2467
|
end
|
|
2340
2468
|
|
|
2341
|
-
#: (
|
|
2342
|
-
def text
|
|
2343
|
-
|
|
2344
|
-
@options[:text] = val.to_s
|
|
2345
|
-
else
|
|
2346
|
-
@options[:text]
|
|
2347
|
-
end
|
|
2469
|
+
#: () -> String?
|
|
2470
|
+
def text
|
|
2471
|
+
@options[:text]
|
|
2348
2472
|
end
|
|
2349
2473
|
|
|
2350
2474
|
#: (String val) -> String
|
|
@@ -2352,13 +2476,9 @@ module Xlsxrb
|
|
|
2352
2476
|
@options[:text] = val.to_s
|
|
2353
2477
|
end
|
|
2354
2478
|
|
|
2355
|
-
#: (
|
|
2356
|
-
def time_period
|
|
2357
|
-
|
|
2358
|
-
@options[:time_period] = val
|
|
2359
|
-
else
|
|
2360
|
-
@options[:time_period]
|
|
2361
|
-
end
|
|
2479
|
+
#: () -> untyped
|
|
2480
|
+
def time_period
|
|
2481
|
+
@options[:time_period]
|
|
2362
2482
|
end
|
|
2363
2483
|
|
|
2364
2484
|
#: (untyped val) -> untyped
|
|
@@ -2366,13 +2486,9 @@ module Xlsxrb
|
|
|
2366
2486
|
@options[:time_period] = val
|
|
2367
2487
|
end
|
|
2368
2488
|
|
|
2369
|
-
#: (
|
|
2370
|
-
def color_scale
|
|
2371
|
-
|
|
2372
|
-
@options[:color_scale] = val
|
|
2373
|
-
else
|
|
2374
|
-
@options[:color_scale]
|
|
2375
|
-
end
|
|
2489
|
+
#: () -> untyped
|
|
2490
|
+
def color_scale
|
|
2491
|
+
@options[:color_scale]
|
|
2376
2492
|
end
|
|
2377
2493
|
|
|
2378
2494
|
#: (untyped val) -> untyped
|
|
@@ -2380,13 +2496,9 @@ module Xlsxrb
|
|
|
2380
2496
|
@options[:color_scale] = val
|
|
2381
2497
|
end
|
|
2382
2498
|
|
|
2383
|
-
#: (
|
|
2384
|
-
def data_bar
|
|
2385
|
-
|
|
2386
|
-
@options[:data_bar] = val
|
|
2387
|
-
else
|
|
2388
|
-
@options[:data_bar]
|
|
2389
|
-
end
|
|
2499
|
+
#: () -> untyped
|
|
2500
|
+
def data_bar
|
|
2501
|
+
@options[:data_bar]
|
|
2390
2502
|
end
|
|
2391
2503
|
|
|
2392
2504
|
#: (untyped val) -> untyped
|
|
@@ -2394,13 +2506,9 @@ module Xlsxrb
|
|
|
2394
2506
|
@options[:data_bar] = val
|
|
2395
2507
|
end
|
|
2396
2508
|
|
|
2397
|
-
#: (
|
|
2398
|
-
def icon_set
|
|
2399
|
-
|
|
2400
|
-
@options[:icon_set] = val
|
|
2401
|
-
else
|
|
2402
|
-
@options[:icon_set]
|
|
2403
|
-
end
|
|
2509
|
+
#: () -> untyped
|
|
2510
|
+
def icon_set
|
|
2511
|
+
@options[:icon_set]
|
|
2404
2512
|
end
|
|
2405
2513
|
|
|
2406
2514
|
#: (untyped val) -> untyped
|
|
@@ -2408,13 +2516,9 @@ module Xlsxrb
|
|
|
2408
2516
|
@options[:icon_set] = val
|
|
2409
2517
|
end
|
|
2410
2518
|
|
|
2411
|
-
#: (
|
|
2412
|
-
def dxf
|
|
2413
|
-
|
|
2414
|
-
@options[:dxf] = val
|
|
2415
|
-
else
|
|
2416
|
-
@options[:dxf]
|
|
2417
|
-
end
|
|
2519
|
+
#: () -> untyped
|
|
2520
|
+
def dxf
|
|
2521
|
+
@options[:dxf]
|
|
2418
2522
|
end
|
|
2419
2523
|
|
|
2420
2524
|
#: (untyped val) -> untyped
|
|
@@ -2422,18 +2526,23 @@ module Xlsxrb
|
|
|
2422
2526
|
@options[:dxf] = val
|
|
2423
2527
|
end
|
|
2424
2528
|
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2529
|
+
# Gets the differential format identifier (dxfId).
|
|
2530
|
+
#
|
|
2531
|
+
# @return [Integer, nil]
|
|
2532
|
+
# @api public
|
|
2533
|
+
#: () -> Integer?
|
|
2534
|
+
def dxf_id
|
|
2535
|
+
@options[:dxf_id]
|
|
2432
2536
|
end
|
|
2433
2537
|
|
|
2538
|
+
# Sets the differential format identifier (dxfId).
|
|
2539
|
+
#
|
|
2540
|
+
# @param val [Integer]
|
|
2541
|
+
# @return [Integer]
|
|
2542
|
+
# @api public
|
|
2434
2543
|
#: (Integer val) -> Integer
|
|
2435
|
-
def
|
|
2436
|
-
@options[:
|
|
2544
|
+
def dxf_id=(val)
|
|
2545
|
+
@options[:dxf_id] = val.to_i
|
|
2437
2546
|
end
|
|
2438
2547
|
|
|
2439
2548
|
#: () -> Hash[Symbol, untyped]
|