xlsxrb 0.1.17 → 0.1.18
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 +93 -1
- data/README.md +79 -19
- data/lib/ruby_lsp/xlsxrb/completion_listener.rb +31 -61
- data/lib/xlsxrb/chart_builder.rb +595 -113
- data/lib/xlsxrb/dsl_helpers.rb +72 -20
- data/lib/xlsxrb/elements/cell.rb +243 -56
- data/lib/xlsxrb/elements/column.rb +94 -5
- data/lib/xlsxrb/elements/coordinate_access.rb +108 -10
- data/lib/xlsxrb/elements/image.rb +81 -15
- data/lib/xlsxrb/elements/metadata.rb +2733 -0
- data/lib/xlsxrb/elements/row.rb +130 -46
- data/lib/xlsxrb/elements/styles.rb +184 -76
- data/lib/xlsxrb/elements/types.rb +242 -7
- data/lib/xlsxrb/elements/workbook.rb +171 -82
- data/lib/xlsxrb/elements/worksheet.rb +598 -102
- data/lib/xlsxrb/elements.rb +1 -0
- data/lib/xlsxrb/ooxml/reader/listeners/core_listeners.rb +12 -4
- data/lib/xlsxrb/ooxml/reader/listeners/drawing_listeners.rb +7 -2
- data/lib/xlsxrb/ooxml/reader/listeners/feature_listeners.rb +264 -17
- data/lib/xlsxrb/ooxml/reader/listeners/style_listeners.rb +17 -3
- data/lib/xlsxrb/ooxml/reader.rb +4 -0
- data/lib/xlsxrb/ooxml/styles_parser.rb +10 -3
- data/lib/xlsxrb/ooxml/workbook_writer.rb +90 -36
- data/lib/xlsxrb/ooxml/worksheet_parser.rb +2 -2
- data/lib/xlsxrb/ooxml/worksheet_writer.rb +64 -19
- data/lib/xlsxrb/ooxml/writer/drawing_xml.rb +5 -2
- data/lib/xlsxrb/ooxml/writer/features_xml.rb +26 -5
- data/lib/xlsxrb/ooxml/writer/styles_xml.rb +19 -9
- data/lib/xlsxrb/ooxml/writer.rb +22 -6
- data/lib/xlsxrb/ooxml/zip_generator.rb +2 -0
- data/lib/xlsxrb/ooxml/zip_reader.rb +47 -10
- data/lib/xlsxrb/stream_row.rb +97 -18
- data/lib/xlsxrb/stream_sheet.rb +706 -190
- data/lib/xlsxrb/stream_writer.rb +1893 -374
- data/lib/xlsxrb/style_builder.rb +774 -111
- data/lib/xlsxrb/utils.rb +66 -106
- data/lib/xlsxrb/version.rb +1 -1
- data/lib/xlsxrb/workbook_builder.rb +380 -83
- data/lib/xlsxrb/worksheet_builder.rb +1210 -233
- data/lib/xlsxrb.rb +1266 -326
- data/sig/generated/xlsxrb/chart_builder.rbs +319 -90
- data/sig/generated/xlsxrb/dsl_helpers.rbs +20 -2
- data/sig/generated/xlsxrb/elements/cell.rbs +92 -20
- data/sig/generated/xlsxrb/elements/column.rbs +61 -2
- data/sig/generated/xlsxrb/elements/coordinate_access.rbs +49 -7
- data/sig/generated/xlsxrb/elements/image.rbs +30 -8
- data/sig/generated/xlsxrb/elements/metadata.rbs +1587 -0
- data/sig/generated/xlsxrb/elements/row.rbs +61 -21
- data/sig/generated/xlsxrb/elements/styles.rbs +96 -58
- data/sig/generated/xlsxrb/elements/types.rbs +27 -0
- data/sig/generated/xlsxrb/elements/workbook.rbs +63 -52
- data/sig/generated/xlsxrb/elements/worksheet.rbs +192 -51
- data/sig/generated/xlsxrb/ooxml/reader/listeners/feature_listeners.rbs +61 -0
- data/sig/generated/xlsxrb/ooxml/reader.rbs +3 -0
- data/sig/generated/xlsxrb/ooxml/workbook_writer.rbs +1 -1
- data/sig/generated/xlsxrb/ooxml/worksheet_writer.rbs +1 -1
- data/sig/generated/xlsxrb/ooxml/writer.rbs +3 -0
- data/sig/generated/xlsxrb/ooxml/zip_generator.rbs +2 -0
- data/sig/generated/xlsxrb/ooxml/zip_reader.rbs +2 -2
- data/sig/generated/xlsxrb/stream_row.rbs +48 -14
- data/sig/generated/xlsxrb/stream_sheet.rbs +324 -115
- data/sig/generated/xlsxrb/stream_writer.rbs +1068 -255
- data/sig/generated/xlsxrb/style_builder.rbs +389 -79
- data/sig/generated/xlsxrb/utils.rbs +34 -18
- data/sig/generated/xlsxrb/workbook_builder.rbs +234 -34
- data/sig/generated/xlsxrb/worksheet_builder.rbs +628 -126
- data/sig/generated/xlsxrb.rbs +257 -49
- metadata +3 -1
data/lib/xlsxrb/stream_writer.rb
CHANGED
|
@@ -24,20 +24,51 @@ module Xlsxrb
|
|
|
24
24
|
#
|
|
25
25
|
# @api public
|
|
26
26
|
class StreamWriter
|
|
27
|
+
OMITTED = Object.new.freeze
|
|
28
|
+
private_constant :OMITTED
|
|
29
|
+
|
|
27
30
|
# @return [String, nil] Name of the currently active worksheet.
|
|
31
|
+
# @api private
|
|
28
32
|
#: String?
|
|
29
33
|
attr_reader :current_sheet
|
|
30
34
|
|
|
31
35
|
# @return [Boolean] Whether to treat strings starting with formula prefixes as plain text.
|
|
36
|
+
#: bool
|
|
32
37
|
attr_accessor :escape_formulas
|
|
33
38
|
|
|
34
|
-
#
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
# Returns whether formula escaping is enabled.
|
|
40
|
+
#
|
|
41
|
+
# @return [Boolean]
|
|
42
|
+
# @api public
|
|
43
|
+
#: () -> bool
|
|
44
|
+
def escape_formulas?
|
|
45
|
+
@escape_formulas ? true : false
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Returns whether the shared strings table is enabled.
|
|
49
|
+
#
|
|
50
|
+
# @return [Boolean]
|
|
51
|
+
# @api public
|
|
52
|
+
#: () -> bool
|
|
53
|
+
def shared_strings?
|
|
54
|
+
@shared_strings ? true : false
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# @deprecated Use {#shared_strings?} instead. Will be removed in 0.2.0.
|
|
58
|
+
#: () -> bool
|
|
59
|
+
def shared_strings
|
|
60
|
+
warn "[DEPRECATION] StreamWriter#shared_strings is deprecated; use #shared_strings? instead.", uplevel: 1
|
|
61
|
+
shared_strings?
|
|
62
|
+
end
|
|
37
63
|
|
|
38
64
|
# @return [Integer] The ZIP deflate compression level (0..9).
|
|
65
|
+
#: Integer
|
|
39
66
|
attr_reader :compression_level
|
|
40
67
|
|
|
68
|
+
# @return [Hash{String => StyleBuilder}]
|
|
69
|
+
#: Hash[String, StyleBuilder]
|
|
70
|
+
attr_reader :styles
|
|
71
|
+
|
|
41
72
|
# Initializes a streaming writer context.
|
|
42
73
|
#
|
|
43
74
|
# @param target [String, IO, StringIO] Destination file path or writable IO stream.
|
|
@@ -109,6 +140,8 @@ module Xlsxrb
|
|
|
109
140
|
@current_phonetic_properties = nil
|
|
110
141
|
@current_sheet_calc_pr = nil
|
|
111
142
|
@current_background_image = nil
|
|
143
|
+
@current_print_area = nil
|
|
144
|
+
@current_print_titles = nil
|
|
112
145
|
@current_row_outline_level = nil
|
|
113
146
|
@current_row_collapsed = false
|
|
114
147
|
@current_row_hidden = false
|
|
@@ -136,62 +169,97 @@ module Xlsxrb
|
|
|
136
169
|
# @param name_or_index [String, Symbol, Integer, nil] Sheet name or 0-based sheet index.
|
|
137
170
|
# @return [String, Symbol, Integer, nil]
|
|
138
171
|
# @api public
|
|
172
|
+
# Gets or sets the active worksheet tab in the workbook window.
|
|
173
|
+
#
|
|
174
|
+
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#active_sheet=} instead.
|
|
175
|
+
# @param name_or_index [String, Symbol, Integer, nil] Sheet name or 0-based sheet index.
|
|
176
|
+
# @return [String, Symbol, Integer, nil]
|
|
177
|
+
# @api public
|
|
139
178
|
#: (?String | Symbol | Integer | nil name_or_index) -> (String | Symbol | Integer | nil)
|
|
140
|
-
def active_sheet(name_or_index =
|
|
141
|
-
if name_or_index
|
|
142
|
-
@active_sheet = name_or_index
|
|
143
|
-
else
|
|
179
|
+
def active_sheet(name_or_index = OMITTED)
|
|
180
|
+
if name_or_index.equal?(OMITTED)
|
|
144
181
|
@active_sheet
|
|
182
|
+
else
|
|
183
|
+
@active_sheet = name_or_index
|
|
145
184
|
end
|
|
146
185
|
end
|
|
147
|
-
|
|
186
|
+
# @deprecated Use {#active_sheet} instead. Will be removed in 0.2.0.
|
|
148
187
|
alias active_tab active_sheet
|
|
149
|
-
|
|
188
|
+
|
|
189
|
+
# Sets the active worksheet tab in the workbook window.
|
|
190
|
+
#
|
|
191
|
+
# @param name_or_index [String, Symbol, Integer, nil] Sheet name or 0-based sheet index.
|
|
192
|
+
# @return [String, Symbol, Integer, nil]
|
|
193
|
+
# @api public
|
|
194
|
+
attr_writer :active_sheet #: (String | Symbol | Integer | nil)
|
|
195
|
+
# @deprecated Use {#active_sheet=} instead. Will be removed in 0.2.0.
|
|
196
|
+
alias active_tab= active_sheet=
|
|
150
197
|
|
|
151
198
|
# Gets or sets the first sheet tab visible in the sheet tab scroll area.
|
|
152
199
|
#
|
|
200
|
+
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#first_sheet=} instead.
|
|
153
201
|
# @param name_or_index [String, Symbol, Integer, nil] Sheet name or 0-based sheet index.
|
|
154
202
|
# @return [String, Symbol, Integer, nil]
|
|
155
203
|
# @api public
|
|
156
204
|
#: (?String | Symbol | Integer | nil name_or_index) -> (String | Symbol | Integer | nil)
|
|
157
|
-
def first_sheet(name_or_index =
|
|
158
|
-
if name_or_index
|
|
159
|
-
@first_sheet = name_or_index
|
|
160
|
-
else
|
|
205
|
+
def first_sheet(name_or_index = OMITTED)
|
|
206
|
+
if name_or_index.equal?(OMITTED)
|
|
161
207
|
@first_sheet
|
|
208
|
+
else
|
|
209
|
+
@first_sheet = name_or_index
|
|
162
210
|
end
|
|
163
211
|
end
|
|
164
|
-
|
|
212
|
+
|
|
213
|
+
# Sets the first sheet tab visible in the sheet tab scroll area.
|
|
214
|
+
#
|
|
215
|
+
# @param name_or_index [String, Symbol, Integer, nil] Sheet name or 0-based sheet index.
|
|
216
|
+
# @return [String, Symbol, Integer, nil]
|
|
217
|
+
# @api public
|
|
218
|
+
attr_writer :first_sheet #: (String | Symbol | Integer | nil)
|
|
165
219
|
|
|
166
220
|
# Gets or sets whether sheet tabs are visible in the workbook window.
|
|
167
221
|
#
|
|
222
|
+
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#show_sheet_tabs=} instead.
|
|
168
223
|
# @param visible [Boolean, nil]
|
|
169
224
|
# @return [Boolean, nil]
|
|
170
225
|
# @api public
|
|
171
226
|
#: (?bool? visible) -> bool?
|
|
172
|
-
def show_sheet_tabs(visible =
|
|
173
|
-
if visible.
|
|
227
|
+
def show_sheet_tabs(visible = OMITTED)
|
|
228
|
+
if visible.equal?(OMITTED)
|
|
174
229
|
@show_sheet_tabs
|
|
175
230
|
else
|
|
176
231
|
@show_sheet_tabs = visible
|
|
177
232
|
end
|
|
178
233
|
end
|
|
179
|
-
|
|
234
|
+
|
|
235
|
+
# Sets whether sheet tabs are visible in the workbook window.
|
|
236
|
+
#
|
|
237
|
+
# @param visible [Boolean, nil]
|
|
238
|
+
# @return [Boolean, nil]
|
|
239
|
+
# @api public
|
|
240
|
+
attr_writer :show_sheet_tabs #: bool?
|
|
180
241
|
|
|
181
242
|
# Gets or sets the ratio between the sheet tabs bar and the horizontal scroll bar (0-1000).
|
|
182
243
|
#
|
|
244
|
+
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#tab_ratio=} instead.
|
|
183
245
|
# @param ratio [Integer, nil]
|
|
184
246
|
# @return [Integer, nil]
|
|
185
247
|
# @api public
|
|
186
248
|
#: (?Integer? ratio) -> Integer?
|
|
187
|
-
def tab_ratio(ratio =
|
|
188
|
-
if ratio
|
|
189
|
-
@tab_ratio = ratio
|
|
190
|
-
else
|
|
249
|
+
def tab_ratio(ratio = OMITTED)
|
|
250
|
+
if ratio.equal?(OMITTED)
|
|
191
251
|
@tab_ratio
|
|
252
|
+
else
|
|
253
|
+
@tab_ratio = ratio
|
|
192
254
|
end
|
|
193
255
|
end
|
|
194
|
-
|
|
256
|
+
|
|
257
|
+
# Sets the ratio between the sheet tabs bar and the horizontal scroll bar (0-1000).
|
|
258
|
+
#
|
|
259
|
+
# @param ratio [Integer, nil]
|
|
260
|
+
# @return [Integer, nil]
|
|
261
|
+
# @api public
|
|
262
|
+
attr_writer :tab_ratio #: Integer?
|
|
195
263
|
|
|
196
264
|
# Sets a workbook property.
|
|
197
265
|
#
|
|
@@ -207,6 +275,25 @@ module Xlsxrb
|
|
|
207
275
|
@workbook_properties[name] = value
|
|
208
276
|
end
|
|
209
277
|
|
|
278
|
+
# Returns workbook-level properties.
|
|
279
|
+
#
|
|
280
|
+
# @return [Elements::WorkbookProperties]
|
|
281
|
+
# @api public
|
|
282
|
+
#: () -> Elements::WorkbookProperties
|
|
283
|
+
def workbook_properties
|
|
284
|
+
Elements::WorkbookProperties.new(**@workbook_properties)
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
# Sets workbook-level properties.
|
|
288
|
+
#
|
|
289
|
+
# @param props [Hash, Elements::MetadataRecord]
|
|
290
|
+
# @return [void]
|
|
291
|
+
# @api public
|
|
292
|
+
#: (untyped props) -> void
|
|
293
|
+
def workbook_properties=(props)
|
|
294
|
+
@workbook_properties = props.is_a?(Elements::MetadataRecord) ? props.to_h : props
|
|
295
|
+
end
|
|
296
|
+
|
|
210
297
|
# Defines or configures a named cell style.
|
|
211
298
|
#
|
|
212
299
|
# @param name [String, Symbol] The name of the style.
|
|
@@ -239,8 +326,44 @@ module Xlsxrb
|
|
|
239
326
|
def default_font(name = nil, size = nil, **opts)
|
|
240
327
|
@style_writer.default_font(name, size, **opts)
|
|
241
328
|
end
|
|
329
|
+
# @deprecated Use {#default_font} instead. Will be removed in 0.2.0.
|
|
242
330
|
alias set_default_font default_font
|
|
243
331
|
|
|
332
|
+
# Creates an {Elements::Formula} object.
|
|
333
|
+
# @api public
|
|
334
|
+
#: (String expression, ?cached_value: (String | Numeric | bool | Elements::CellError | nil), ?type: (Symbol | String)?, ?ref: String?, ?shared_index: Integer?) -> Elements::Formula
|
|
335
|
+
def formula(...)
|
|
336
|
+
Xlsxrb.formula(...)
|
|
337
|
+
end
|
|
338
|
+
|
|
339
|
+
# Creates an array or dynamic array {Elements::Formula} object.
|
|
340
|
+
# @api public
|
|
341
|
+
#: (String expression, ?ref: String?, ?cached_value: (String | Numeric | bool | Elements::CellError | nil), **untyped attrs) -> Elements::Formula
|
|
342
|
+
def array_formula(...)
|
|
343
|
+
Xlsxrb.array_formula(...)
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
# Creates a shared formula {Elements::Formula} object.
|
|
347
|
+
# @api public
|
|
348
|
+
#: (?String? expression, ?shared_index: Integer?, ?ref: String?, ?cached_value: (String | Numeric | bool | Elements::CellError | nil)) -> Elements::Formula
|
|
349
|
+
def shared_formula(...)
|
|
350
|
+
Xlsxrb.shared_formula(...)
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
# Creates an {Elements::RichText} object.
|
|
354
|
+
# @api public
|
|
355
|
+
#: (*(Hash[Symbol, untyped] | Elements::RichTextRun | String | Array[untyped] | untyped) runs, ?text: String?, ?base_font: untyped, **untyped font_props) -> Elements::RichText
|
|
356
|
+
def rich_text(...)
|
|
357
|
+
Xlsxrb.rich_text(...)
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
# Creates or returns an {Elements::CellError} object.
|
|
361
|
+
# @api public
|
|
362
|
+
#: (String | Symbol | Elements::CellError code) -> Elements::CellError
|
|
363
|
+
def cell_error(...)
|
|
364
|
+
Xlsxrb.cell_error(...)
|
|
365
|
+
end
|
|
366
|
+
|
|
244
367
|
# Proxy object yielded by the `sheet` method to prevent writing to inactive sheets in streaming mode.
|
|
245
368
|
#
|
|
246
369
|
# @api public
|
|
@@ -263,8 +386,62 @@ module Xlsxrb
|
|
|
263
386
|
def default_font(...)
|
|
264
387
|
@writer.default_font(...)
|
|
265
388
|
end
|
|
389
|
+
# @deprecated Use {#default_font} instead. Will be removed in 0.2.0.
|
|
266
390
|
alias set_default_font default_font
|
|
267
391
|
|
|
392
|
+
# Creates an {Elements::Formula} object.
|
|
393
|
+
# @api public
|
|
394
|
+
#: (String expression, ?cached_value: (String | Numeric | bool | Elements::CellError | nil), ?type: (Symbol | String)?, ?ref: String?, ?shared_index: Integer?) -> Elements::Formula
|
|
395
|
+
def formula(...)
|
|
396
|
+
Xlsxrb.formula(...)
|
|
397
|
+
end
|
|
398
|
+
|
|
399
|
+
# Creates an array or dynamic array {Elements::Formula} object.
|
|
400
|
+
# @api public
|
|
401
|
+
#: (String expression, ?ref: String?, ?cached_value: (String | Numeric | bool | Elements::CellError | nil), **untyped attrs) -> Elements::Formula
|
|
402
|
+
def array_formula(...)
|
|
403
|
+
Xlsxrb.array_formula(...)
|
|
404
|
+
end
|
|
405
|
+
|
|
406
|
+
# Creates a shared formula {Elements::Formula} object.
|
|
407
|
+
# @api public
|
|
408
|
+
#: (?String? expression, ?shared_index: Integer?, ?ref: String?, ?cached_value: (String | Numeric | bool | Elements::CellError | nil)) -> Elements::Formula
|
|
409
|
+
def shared_formula(...)
|
|
410
|
+
Xlsxrb.shared_formula(...)
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
# Creates an {Elements::RichText} object.
|
|
414
|
+
# @api public
|
|
415
|
+
#: (*(Hash[Symbol, untyped] | Elements::RichTextRun | String | Array[untyped] | untyped) runs, ?text: String?, ?base_font: untyped, **untyped font_props) -> Elements::RichText
|
|
416
|
+
def rich_text(...)
|
|
417
|
+
Xlsxrb.rich_text(...)
|
|
418
|
+
end
|
|
419
|
+
|
|
420
|
+
# Creates or returns an {Elements::CellError} object.
|
|
421
|
+
# @api public
|
|
422
|
+
#: (String | Symbol | Elements::CellError code) -> Elements::CellError
|
|
423
|
+
def cell_error(...)
|
|
424
|
+
Xlsxrb.cell_error(...)
|
|
425
|
+
end
|
|
426
|
+
|
|
427
|
+
# Returns the worksheet name.
|
|
428
|
+
#
|
|
429
|
+
# @return [String]
|
|
430
|
+
# @api public
|
|
431
|
+
#: () -> String
|
|
432
|
+
def name
|
|
433
|
+
@sheet_name
|
|
434
|
+
end
|
|
435
|
+
|
|
436
|
+
# Returns column configurations defined for this worksheet.
|
|
437
|
+
#
|
|
438
|
+
# @return [Array<Elements::Column>]
|
|
439
|
+
# @api public
|
|
440
|
+
#: () -> Array[Elements::Column]
|
|
441
|
+
def columns
|
|
442
|
+
@writer.columns
|
|
443
|
+
end
|
|
444
|
+
|
|
268
445
|
# Returns the list of worksheet names created in this workbook so far.
|
|
269
446
|
#
|
|
270
447
|
# @return [Array<String>] Worksheet names.
|
|
@@ -274,6 +451,31 @@ module Xlsxrb
|
|
|
274
451
|
@writer.sheet_names
|
|
275
452
|
end
|
|
276
453
|
|
|
454
|
+
# Returns whether formula escaping is enabled.
|
|
455
|
+
#
|
|
456
|
+
# @return [Boolean]
|
|
457
|
+
# @api public
|
|
458
|
+
#: () -> bool
|
|
459
|
+
def escape_formulas?
|
|
460
|
+
@writer.escape_formulas?
|
|
461
|
+
end
|
|
462
|
+
|
|
463
|
+
# @return [Boolean] Whether to treat strings starting with formula prefixes as plain text.
|
|
464
|
+
#: bool
|
|
465
|
+
def escape_formulas
|
|
466
|
+
@writer.escape_formulas
|
|
467
|
+
end
|
|
468
|
+
|
|
469
|
+
# Sets whether to treat strings starting with formula prefixes as plain text.
|
|
470
|
+
#
|
|
471
|
+
# @param val [Boolean]
|
|
472
|
+
# @return [Boolean]
|
|
473
|
+
# @api public
|
|
474
|
+
#: (bool val) -> bool
|
|
475
|
+
def escape_formulas=(val, ...)
|
|
476
|
+
@writer.escape_formulas = val
|
|
477
|
+
end
|
|
478
|
+
|
|
277
479
|
# Defines or configures a named cell style on the active sheet.
|
|
278
480
|
#
|
|
279
481
|
# @example
|
|
@@ -297,10 +499,8 @@ module Xlsxrb
|
|
|
297
499
|
# @example Merge with cell reference string
|
|
298
500
|
# s.merge("A1:C1")
|
|
299
501
|
#
|
|
300
|
-
# @
|
|
301
|
-
#
|
|
302
|
-
#
|
|
303
|
-
# @param range [String, nil] The cell range (e.g. "A1:B2").
|
|
502
|
+
# @deprecated Passing coordinate keyword arguments (row:, col_start:, col_end:, row_start:, row_end:) is deprecated and will be removed in 0.2.0. Use a range string (e.g. merge("A1:C1")) instead.
|
|
503
|
+
# @param range [String, Hash, nil] The cell range (e.g. "A1:B2").
|
|
304
504
|
# @param row [Integer, nil] 0-based row index.
|
|
305
505
|
# @param col_start [Integer, String, nil] 0-based start column index or letter.
|
|
306
506
|
# @param col_end [Integer, String, nil] 0-based end column index or letter.
|
|
@@ -308,7 +508,7 @@ module Xlsxrb
|
|
|
308
508
|
# @param row_end [Integer, nil] 0-based end row index.
|
|
309
509
|
# @return [void]
|
|
310
510
|
# @api public
|
|
311
|
-
#: (?String? range, ?row: Integer | nil, ?col_start: (Integer | String)?, ?col_end: (Integer | String)?, ?row_start: Integer | nil, ?row_end: Integer | nil) -> void
|
|
511
|
+
#: (?(String | Hash[Symbol, Integer | String])? range, ?row: Integer | nil, ?col_start: (Integer | String)?, ?col_end: (Integer | String)?, ?row_start: Integer | nil, ?row_end: Integer | nil) -> void
|
|
312
512
|
def merge(...)
|
|
313
513
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
314
514
|
|
|
@@ -322,14 +522,16 @@ module Xlsxrb
|
|
|
322
522
|
#
|
|
323
523
|
# @param preset [String] Preset shape type (e.g. "rect", "ellipse").
|
|
324
524
|
# @param text [String, nil] Shape label text.
|
|
325
|
-
# @param
|
|
525
|
+
# @param from_column [Integer, nil] Starting column index (0-based).
|
|
526
|
+
# @param from_col [Integer, nil] Deprecated alias for from_column.
|
|
326
527
|
# @param from_row [Integer] Starting row index (0-based).
|
|
327
|
-
# @param
|
|
528
|
+
# @param to_column [Integer, nil] Ending column index (0-based).
|
|
529
|
+
# @param to_col [Integer, nil] Deprecated alias for to_column.
|
|
328
530
|
# @param to_row [Integer] Ending row index (0-based).
|
|
329
531
|
# @param opts [Hash] Additional shape formatting options.
|
|
330
532
|
# @return [void]
|
|
331
533
|
# @api public
|
|
332
|
-
#: (?preset: String, ?text: String?, ?from_col: Integer
|
|
534
|
+
#: (?preset: String, ?text: String?, ?from_column: Integer?, ?from_col: Integer?, ?from_row: Integer, ?to_column: Integer?, ?to_col: Integer?, ?to_row: Integer, **untyped opts) -> void
|
|
333
535
|
def shape(...)
|
|
334
536
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
335
537
|
|
|
@@ -338,6 +540,7 @@ module Xlsxrb
|
|
|
338
540
|
|
|
339
541
|
# simplecov:disable
|
|
340
542
|
# Edge case / untested delegation block
|
|
543
|
+
# @api private
|
|
341
544
|
#: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
|
|
342
545
|
def internal_sheet_setup(...)
|
|
343
546
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
@@ -352,24 +555,36 @@ module Xlsxrb
|
|
|
352
555
|
# s.row(["Name", "Age", "City"])
|
|
353
556
|
#
|
|
354
557
|
# @example Write with explicit column keys and styles
|
|
355
|
-
# s.row({ A: "Header", C: 100 },
|
|
558
|
+
# s.row({ A: "Header", C: 100 }, cell_styles: { A: :bold })
|
|
356
559
|
#
|
|
357
560
|
# @param values [Array, Hash] The cell values (e.g. `[1, 2, 3]` or `{ A: 1, C: 3 }`).
|
|
358
|
-
# @param
|
|
561
|
+
# @param cell_styles [String, Symbol, Array, Hash, nil] Style names or hashes to apply to cells.
|
|
562
|
+
# @param row_style [Integer, Symbol, String, Hash, nil] Row style format or index.
|
|
359
563
|
# @param height [Float, Integer, nil] The row height in points (0 - 409).
|
|
360
564
|
# @param hidden [Boolean] Whether the row is hidden.
|
|
361
565
|
# @param custom_height [Boolean] Whether to flag as custom height.
|
|
362
566
|
# @param outline_level [Integer, nil] Grouping/outline level (0 - 7).
|
|
363
567
|
# @param collapsed [Boolean] Whether the row is collapsed.
|
|
364
|
-
# @param
|
|
568
|
+
# @param styles [String, Symbol, Array, Hash, nil] Deprecated. Use cell_styles: instead.
|
|
569
|
+
# @param style [Integer, Symbol, String, Hash, nil] Deprecated. Use row_style: instead.
|
|
365
570
|
# @return [void]
|
|
366
571
|
# @api public
|
|
367
|
-
#: (Array[untyped] | Hash[untyped, untyped] values, ?styles: untyped, ?height: Float | Integer | nil, ?hidden: bool, ?custom_height: bool, ?collapsed: bool, ?outline_level: Integer | nil
|
|
368
|
-
def row(values, styles: nil, height: nil, hidden: false, custom_height: false, collapsed: false, outline_level: nil
|
|
572
|
+
#: (Array[untyped] | Hash[untyped, untyped] values, ?cell_styles: untyped, ?row_style: untyped, ?styles: untyped, ?style: untyped, ?height: Float | Integer | nil, ?hidden: bool, ?custom_height: bool, ?collapsed: bool, ?outline_level: Integer | nil) -> void
|
|
573
|
+
def row(values, cell_styles: nil, row_style: nil, styles: nil, style: nil, height: nil, hidden: false, custom_height: false, collapsed: false, outline_level: nil)
|
|
369
574
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
370
575
|
|
|
371
|
-
|
|
576
|
+
if styles
|
|
577
|
+
warn "[DEPRECATION] WorksheetProxy#row keyword :styles is deprecated; use :cell_styles instead.", uplevel: 1
|
|
578
|
+
cell_styles ||= styles
|
|
579
|
+
end
|
|
580
|
+
if style
|
|
581
|
+
warn "[DEPRECATION] WorksheetProxy#row keyword :style is deprecated; use :row_style instead.", uplevel: 1
|
|
582
|
+
row_style ||= style
|
|
583
|
+
end
|
|
584
|
+
|
|
585
|
+
@writer.row(values, cell_styles: cell_styles, row_style: row_style, height: height, hidden: hidden, custom_height: custom_height, collapsed: collapsed, outline_level: outline_level)
|
|
372
586
|
end
|
|
587
|
+
# @deprecated Use {#row} instead. Will be removed in 0.2.0.
|
|
373
588
|
alias add_row row
|
|
374
589
|
|
|
375
590
|
# Appends a row to the worksheet and returns self for chaining.
|
|
@@ -403,6 +618,7 @@ module Xlsxrb
|
|
|
403
618
|
|
|
404
619
|
@writer.skip_rows(count)
|
|
405
620
|
end
|
|
621
|
+
# @deprecated Use {#skip_rows} instead. Will be removed in 0.2.0.
|
|
406
622
|
alias skip_row skip_rows
|
|
407
623
|
|
|
408
624
|
# Configures column width and properties.
|
|
@@ -410,17 +626,17 @@ module Xlsxrb
|
|
|
410
626
|
# @example Set column A width
|
|
411
627
|
# s.column(0, width: 25.0)
|
|
412
628
|
#
|
|
413
|
-
# @param
|
|
629
|
+
# @param index [Integer, String, Symbol, Range, Array] 0-based column index, letter ("A", :A), range, or array.
|
|
414
630
|
# @param width [Float, Integer, nil] Column width in characters.
|
|
415
631
|
# @param hidden [Boolean] Whether the column is hidden.
|
|
416
|
-
# @param best_fit [Boolean] Whether the column automatically fits content.
|
|
417
632
|
# @param custom_width [Boolean] Whether to flag as custom width.
|
|
418
633
|
# @param outline_level [Integer, nil] Grouping/outline level (0 - 7).
|
|
419
634
|
# @param collapsed [Boolean] Whether the outline group is collapsed.
|
|
420
635
|
# @param style [Integer, Symbol, String, Hash, nil] Column style format or index.
|
|
636
|
+
# @param best_fit [Boolean] Whether the column automatically fits content.
|
|
421
637
|
# @return [void]
|
|
422
638
|
# @api public
|
|
423
|
-
#: (Integer | String | Symbol | Range[Integer | String] | Array[Integer | String]
|
|
639
|
+
#: (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
|
|
424
640
|
def column(...)
|
|
425
641
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
426
642
|
|
|
@@ -443,8 +659,11 @@ module Xlsxrb
|
|
|
443
659
|
|
|
444
660
|
@writer.group_columns(...)
|
|
445
661
|
end
|
|
662
|
+
# @deprecated Use {#group_columns} instead. Will be removed in 0.2.0.
|
|
446
663
|
alias group_column group_columns
|
|
664
|
+
# @deprecated Use {#group_columns} instead. Will be removed in 0.2.0.
|
|
447
665
|
alias group_cols group_columns
|
|
666
|
+
# @deprecated Use {#group_columns} instead. Will be removed in 0.2.0.
|
|
448
667
|
alias group_col group_columns
|
|
449
668
|
|
|
450
669
|
# Groups multiple rows with outline hierarchy with a block.
|
|
@@ -468,6 +687,7 @@ module Xlsxrb
|
|
|
468
687
|
@writer.group_rows(rows, level: level, collapsed: collapsed, hidden: hidden)
|
|
469
688
|
end
|
|
470
689
|
end
|
|
690
|
+
# @deprecated Use {#group_rows} instead. Will be removed in 0.2.0.
|
|
471
691
|
alias group_row group_rows
|
|
472
692
|
|
|
473
693
|
# Configures worksheet-level outline and grouping view properties.
|
|
@@ -475,19 +695,34 @@ module Xlsxrb
|
|
|
475
695
|
# @param summary_below [Boolean, nil] Summary rows below detail rows.
|
|
476
696
|
# @param summary_right [Boolean, nil] Summary columns to the right of detail columns.
|
|
477
697
|
# @param show_outline_symbols [Boolean, nil] Outline symbols visible.
|
|
478
|
-
# @param show_symbols [Boolean, nil]
|
|
698
|
+
# @param show_symbols [Boolean, nil] Deprecated alias for show_outline_symbols.
|
|
479
699
|
# @param apply_styles [Boolean, nil] Automatic styles applied.
|
|
480
700
|
# @param opts [Hash] Additional options.
|
|
481
|
-
# @return [
|
|
701
|
+
# @return [void]
|
|
482
702
|
# @api public
|
|
483
|
-
#: (?summary_below: bool?, ?summary_right: bool?, ?show_outline_symbols: bool?, ?show_symbols: bool?, ?apply_styles: bool?, **untyped opts) ->
|
|
484
|
-
def outline_properties(
|
|
703
|
+
#: (?summary_below: bool?, ?summary_right: bool?, ?show_outline_symbols: bool?, ?show_symbols: bool?, ?apply_styles: bool?, **untyped opts) -> void
|
|
704
|
+
def outline_properties(summary_below: nil, summary_right: nil, show_outline_symbols: nil, show_symbols: nil, apply_styles: nil, **opts)
|
|
485
705
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
486
706
|
|
|
487
|
-
|
|
707
|
+
warn "[Xlsxrb DEPRECATION] outline_properties keyword show_symbols: is deprecated; use show_outline_symbols: instead.", uplevel: 1 unless show_symbols.nil?
|
|
708
|
+
@writer.outline_properties(summary_below: summary_below, summary_right: summary_right, show_outline_symbols: show_outline_symbols || show_symbols, apply_styles: apply_styles, **opts)
|
|
488
709
|
end
|
|
710
|
+
# @deprecated Use {#outline_properties} instead. Will be removed in 0.2.0.
|
|
489
711
|
alias outline_pr outline_properties
|
|
490
712
|
|
|
713
|
+
# Sets worksheet outline and grouping view properties.
|
|
714
|
+
#
|
|
715
|
+
# @param opts [Hash] Outline properties.
|
|
716
|
+
# @return [void]
|
|
717
|
+
# @api public
|
|
718
|
+
#: (Hash[Symbol, untyped] opts) -> void
|
|
719
|
+
def outline_properties=(opts)
|
|
720
|
+
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
721
|
+
|
|
722
|
+
@writer.outline_properties = opts
|
|
723
|
+
end
|
|
724
|
+
alias outline_pr= outline_properties=
|
|
725
|
+
|
|
491
726
|
# Adds a chart to the active sheet.
|
|
492
727
|
#
|
|
493
728
|
# @example
|
|
@@ -497,12 +732,12 @@ module Xlsxrb
|
|
|
497
732
|
# end
|
|
498
733
|
#
|
|
499
734
|
# @param type [Symbol, String, nil] The chart type (:bar, :col, :line, :pie, :scatter, :area, :doughnut, :radar).
|
|
500
|
-
# @param
|
|
735
|
+
# @param options [Hash] Additional chart options.
|
|
501
736
|
# @yield [chart_builder]
|
|
502
737
|
# @yieldparam chart_builder [Xlsxrb::ChartBuilder]
|
|
503
738
|
# @return [void]
|
|
504
739
|
# @api public
|
|
505
|
-
#: (?Symbol | String? type, **untyped
|
|
740
|
+
#: (?Symbol | String? type, **untyped options) ?{ (ChartBuilder) -> void } -> void
|
|
506
741
|
def chart(...)
|
|
507
742
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
508
743
|
|
|
@@ -536,26 +771,38 @@ module Xlsxrb
|
|
|
536
771
|
# @example
|
|
537
772
|
# s.auto_filter("A1:D100")
|
|
538
773
|
#
|
|
539
|
-
# @param
|
|
774
|
+
# @param range [String, nil] The cell range (e.g. "A1:D10").
|
|
540
775
|
# @return [void]
|
|
541
776
|
# @api public
|
|
542
|
-
#: (String
|
|
777
|
+
#: (String? range) -> void
|
|
543
778
|
def auto_filter(...)
|
|
544
779
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
545
780
|
|
|
546
781
|
@writer.auto_filter(...)
|
|
547
782
|
end
|
|
548
783
|
|
|
784
|
+
# Sets the auto-filter range on the active sheet.
|
|
785
|
+
#
|
|
786
|
+
# @param range [String, nil] The cell range (e.g. "A1:D10").
|
|
787
|
+
# @return [String, nil]
|
|
788
|
+
# @api public
|
|
789
|
+
#: (String? range) -> String?
|
|
790
|
+
def auto_filter=(range)
|
|
791
|
+
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
792
|
+
|
|
793
|
+
@writer.auto_filter = range
|
|
794
|
+
end
|
|
795
|
+
|
|
549
796
|
# Sets filter criteria for a column in the auto-filter.
|
|
550
797
|
#
|
|
551
798
|
# @example Simple values filter
|
|
552
799
|
# s.filter_column(0, ["Active", "Pending"])
|
|
553
800
|
#
|
|
554
|
-
# @param col_id [Integer] 0-based column index relative to auto-filter range.
|
|
555
|
-
# @param
|
|
801
|
+
# @param col_id [Integer, String, Symbol] 0-based column index relative to auto-filter range or column letter.
|
|
802
|
+
# @param filter [Hash] Values or filter specification hash.
|
|
556
803
|
# @return [void]
|
|
557
804
|
# @api public
|
|
558
|
-
#: (Integer
|
|
805
|
+
#: (Integer | String | Symbol col_id, Hash[untyped, untyped] filter) -> void
|
|
559
806
|
def filter_column(...)
|
|
560
807
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
561
808
|
|
|
@@ -568,26 +815,36 @@ module Xlsxrb
|
|
|
568
815
|
# s.sort_state("A1:A10", [{ ref: "A1:A10", descending: true }])
|
|
569
816
|
#
|
|
570
817
|
# @param ref [String] The range to sort.
|
|
571
|
-
# @param sort_conditions [Array<Hash
|
|
818
|
+
# @param sort_conditions [Array<Hash>] Sort conditions array.
|
|
572
819
|
# @param opts [Hash] Additional sort options.
|
|
573
820
|
# @return [void]
|
|
574
821
|
# @api public
|
|
575
|
-
#: (String ref, Array[Hash[
|
|
822
|
+
#: (String ref, Array[Hash[untyped, untyped]] sort_conditions, **untyped opts) -> void
|
|
576
823
|
def sort_state(...)
|
|
577
824
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
578
825
|
|
|
579
826
|
@writer.sort_state(...)
|
|
580
827
|
end
|
|
581
828
|
|
|
582
|
-
#
|
|
829
|
+
# Sets column sort state for the sheet.
|
|
583
830
|
#
|
|
584
|
-
#
|
|
831
|
+
# @param opts [Elements::SortState, Hash, nil] Sort state options.
|
|
832
|
+
# @return [void]
|
|
833
|
+
# @api public
|
|
834
|
+
#: (untyped opts) -> void
|
|
835
|
+
def sort_state=(opts)
|
|
836
|
+
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
837
|
+
|
|
838
|
+
@writer.sort_state = opts
|
|
839
|
+
end
|
|
840
|
+
|
|
841
|
+
# Adds data validation rules to a range.
|
|
585
842
|
#
|
|
586
843
|
# @example Dropdown list validation
|
|
587
|
-
# s.
|
|
844
|
+
# s.data_validation("B2:B100", type: "list", formula1: '"High,Medium,Low"')
|
|
588
845
|
#
|
|
589
846
|
# @example Block syntax
|
|
590
|
-
# s.
|
|
847
|
+
# s.data_validation("B2:B100") do |dv|
|
|
591
848
|
# dv.type :list
|
|
592
849
|
# dv.formula1 '"High,Medium,Low"'
|
|
593
850
|
# end
|
|
@@ -599,10 +856,17 @@ module Xlsxrb
|
|
|
599
856
|
# @return [void]
|
|
600
857
|
# @api public
|
|
601
858
|
#: (?String? range, ?type: (String | Symbol)?, **untyped opts) ?{ (DataValidationBuilder) -> void } -> void
|
|
602
|
-
def
|
|
859
|
+
def data_validation(...)
|
|
603
860
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
604
861
|
|
|
605
|
-
@writer.
|
|
862
|
+
@writer.data_validation(...)
|
|
863
|
+
end
|
|
864
|
+
|
|
865
|
+
# @deprecated Use {#data_validation} instead.
|
|
866
|
+
#: (?String? range, ?type: (String | Symbol)?, **untyped opts) ?{ (DataValidationBuilder) -> void } -> void
|
|
867
|
+
def validate_data(...)
|
|
868
|
+
warn "[DEPRECATION] `validate_data` is deprecated; use `data_validation` instead.", uplevel: 1
|
|
869
|
+
data_validation(...)
|
|
606
870
|
end
|
|
607
871
|
|
|
608
872
|
# Adds conditional formatting to a range.
|
|
@@ -658,6 +922,7 @@ module Xlsxrb
|
|
|
658
922
|
|
|
659
923
|
# simplecov:disable
|
|
660
924
|
# Edge case / untested delegation block
|
|
925
|
+
# @api private
|
|
661
926
|
#: () -> void
|
|
662
927
|
def cleanup!(...)
|
|
663
928
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
@@ -697,6 +962,7 @@ module Xlsxrb
|
|
|
697
962
|
|
|
698
963
|
@writer.threaded_comment(...)
|
|
699
964
|
end
|
|
965
|
+
# @deprecated Use {#threaded_comment} instead. Will be removed in 0.2.0.
|
|
700
966
|
alias add_threaded_comment threaded_comment
|
|
701
967
|
|
|
702
968
|
# Adds a Pivot Table to the sheet.
|
|
@@ -704,15 +970,17 @@ module Xlsxrb
|
|
|
704
970
|
# @param source_ref [String] Source data range reference (e.g. "Sheet1!A1:D100").
|
|
705
971
|
# @param row_fields [Array<String>] Field names for rows.
|
|
706
972
|
# @param data_fields [Array<String>] Field names for data values.
|
|
707
|
-
# @param
|
|
708
|
-
# @param
|
|
973
|
+
# @param column_fields [Array<String>] Field names for columns.
|
|
974
|
+
# @param col_fields [Array<String>] Deprecated alias for column_fields.
|
|
975
|
+
# @param ref [String] Target top-left cell reference (default: "E1").
|
|
976
|
+
# @param dest_ref [String] Deprecated alias for ref.
|
|
709
977
|
# @param name [String, nil] Pivot table name.
|
|
710
978
|
# @param field_names [Array<String>, nil] Override field names.
|
|
711
979
|
# @param items [Array, nil] Items configuration.
|
|
712
980
|
# @param opts [Hash] Additional options.
|
|
713
981
|
# @return [void]
|
|
714
982
|
# @api public
|
|
715
|
-
#: (String source_ref, row_fields: untyped, data_fields: untyped, ?col_fields: untyped, ?dest_ref: String
|
|
983
|
+
#: (String source_ref, row_fields: untyped, data_fields: untyped, ?column_fields: untyped, ?col_fields: untyped, ?ref: String?, ?dest_ref: String?, ?name: String?, ?field_names: untyped, ?items: untyped, **untyped opts) -> void
|
|
716
984
|
def pivot_table(...)
|
|
717
985
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
718
986
|
|
|
@@ -751,10 +1019,12 @@ module Xlsxrb
|
|
|
751
1019
|
# @param range [String, nil] Data range for the sparkline (e.g. "A1:E1").
|
|
752
1020
|
# @param type [Symbol, String, nil] Sparkline type (:line, :column, :win_loss / :stacked).
|
|
753
1021
|
# @param opts [Hash] Additional sparkline options.
|
|
1022
|
+
# @deprecated Use {#sparkline_group} instead. Will be removed in 0.2.0.
|
|
754
1023
|
# @return [void]
|
|
755
1024
|
# @api public
|
|
756
1025
|
#: (?location: String?, ?range: String?, ?type: (String | Symbol)?, **untyped opts) -> void
|
|
757
1026
|
def add_sparkline(...)
|
|
1027
|
+
warn "[DEPRECATION] #add_sparkline is deprecated; use #sparkline_group instead.", uplevel: 1
|
|
758
1028
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
759
1029
|
|
|
760
1030
|
@writer.add_sparkline(...)
|
|
@@ -762,10 +1032,11 @@ module Xlsxrb
|
|
|
762
1032
|
|
|
763
1033
|
# Sets workbook-level properties.
|
|
764
1034
|
#
|
|
765
|
-
# @param
|
|
1035
|
+
# @param name [Symbol] Workbook property name.
|
|
1036
|
+
# @param value [String, Integer, Boolean] Property value.
|
|
766
1037
|
# @return [void]
|
|
767
1038
|
# @api public
|
|
768
|
-
#: (
|
|
1039
|
+
#: (Symbol name, String | Integer | bool value) -> void
|
|
769
1040
|
def workbook_property(...)
|
|
770
1041
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
771
1042
|
|
|
@@ -775,6 +1046,7 @@ module Xlsxrb
|
|
|
775
1046
|
# Sets or gets the active sheet in the workbook window.
|
|
776
1047
|
# If called without arguments on the proxy, marks this sheet as the active sheet.
|
|
777
1048
|
#
|
|
1049
|
+
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#active_sheet=} instead.
|
|
778
1050
|
# @param name_or_index [String, Symbol, Integer, nil]
|
|
779
1051
|
# @return [String, Symbol, Integer, nil]
|
|
780
1052
|
# @api public
|
|
@@ -784,10 +1056,26 @@ module Xlsxrb
|
|
|
784
1056
|
|
|
785
1057
|
@writer.active_sheet(name_or_index)
|
|
786
1058
|
end
|
|
1059
|
+
# @deprecated Use {#active_sheet} instead. Will be removed in 0.2.0.
|
|
787
1060
|
alias active_tab active_sheet
|
|
788
1061
|
|
|
1062
|
+
# Sets the active worksheet tab in the workbook window.
|
|
1063
|
+
#
|
|
1064
|
+
# @param name_or_index [String, Symbol, Integer, nil] Sheet name or 0-based sheet index.
|
|
1065
|
+
# @return [String, Symbol, Integer, nil]
|
|
1066
|
+
# @api public
|
|
1067
|
+
#: (String | Symbol | Integer | nil name_or_index) -> (String | Symbol | Integer | nil)
|
|
1068
|
+
def active_sheet=(name_or_index)
|
|
1069
|
+
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1070
|
+
|
|
1071
|
+
@writer.active_sheet = name_or_index
|
|
1072
|
+
end
|
|
1073
|
+
# @deprecated Use {#active_sheet=} instead. Will be removed in 0.2.0.
|
|
1074
|
+
alias active_tab= active_sheet=
|
|
1075
|
+
|
|
789
1076
|
# Sets or gets the first visible sheet in the tab bar.
|
|
790
1077
|
#
|
|
1078
|
+
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#first_sheet=} instead.
|
|
791
1079
|
# @param name_or_index [String, Symbol, Integer, nil]
|
|
792
1080
|
# @return [String, Symbol, Integer, nil]
|
|
793
1081
|
# @api public
|
|
@@ -798,8 +1086,21 @@ module Xlsxrb
|
|
|
798
1086
|
@writer.first_sheet(name_or_index)
|
|
799
1087
|
end
|
|
800
1088
|
|
|
1089
|
+
# Sets the first visible sheet in the tab bar.
|
|
1090
|
+
#
|
|
1091
|
+
# @param name_or_index [String, Symbol, Integer, nil] Sheet name or 0-based sheet index.
|
|
1092
|
+
# @return [String, Symbol, Integer, nil]
|
|
1093
|
+
# @api public
|
|
1094
|
+
#: (String | Symbol | Integer | nil name_or_index) -> (String | Symbol | Integer | nil)
|
|
1095
|
+
def first_sheet=(name_or_index)
|
|
1096
|
+
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1097
|
+
|
|
1098
|
+
@writer.first_sheet = name_or_index
|
|
1099
|
+
end
|
|
1100
|
+
|
|
801
1101
|
# Sets or gets whether sheet tabs are visible in the workbook window.
|
|
802
1102
|
#
|
|
1103
|
+
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#show_sheet_tabs=} instead.
|
|
803
1104
|
# @param visible [Boolean, nil]
|
|
804
1105
|
# @return [Boolean, nil]
|
|
805
1106
|
# @api public
|
|
@@ -810,8 +1111,21 @@ module Xlsxrb
|
|
|
810
1111
|
@writer.show_sheet_tabs(visible)
|
|
811
1112
|
end
|
|
812
1113
|
|
|
1114
|
+
# Sets whether sheet tabs are visible in the workbook window.
|
|
1115
|
+
#
|
|
1116
|
+
# @param visible [Boolean, nil]
|
|
1117
|
+
# @return [Boolean, nil]
|
|
1118
|
+
# @api public
|
|
1119
|
+
#: (bool? visible) -> bool?
|
|
1120
|
+
def show_sheet_tabs=(visible)
|
|
1121
|
+
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1122
|
+
|
|
1123
|
+
@writer.show_sheet_tabs = visible
|
|
1124
|
+
end
|
|
1125
|
+
|
|
813
1126
|
# Sets or gets the tab ratio between tab bar and horizontal scrollbar (0-1000).
|
|
814
1127
|
#
|
|
1128
|
+
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#tab_ratio=} instead.
|
|
815
1129
|
# @param ratio [Integer, nil]
|
|
816
1130
|
# @return [Integer, nil]
|
|
817
1131
|
# @api public
|
|
@@ -822,8 +1136,21 @@ module Xlsxrb
|
|
|
822
1136
|
@writer.tab_ratio(ratio)
|
|
823
1137
|
end
|
|
824
1138
|
|
|
1139
|
+
# Sets the tab ratio between tab bar and horizontal scrollbar (0-1000).
|
|
1140
|
+
#
|
|
1141
|
+
# @param ratio [Integer, nil]
|
|
1142
|
+
# @return [Integer, nil]
|
|
1143
|
+
# @api public
|
|
1144
|
+
#: (Integer? ratio) -> Integer?
|
|
1145
|
+
def tab_ratio=(ratio)
|
|
1146
|
+
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1147
|
+
|
|
1148
|
+
@writer.tab_ratio = ratio
|
|
1149
|
+
end
|
|
1150
|
+
|
|
825
1151
|
# Gets or sets the sheet visibility state (:visible, :hidden, or :very_hidden).
|
|
826
1152
|
#
|
|
1153
|
+
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#state=} instead.
|
|
827
1154
|
# @param new_state [Symbol, nil] The new state.
|
|
828
1155
|
# @return [Symbol]
|
|
829
1156
|
# @api public
|
|
@@ -834,8 +1161,22 @@ module Xlsxrb
|
|
|
834
1161
|
@writer.state(new_state)
|
|
835
1162
|
end
|
|
836
1163
|
|
|
1164
|
+
# Sets the sheet visibility state (:visible, :hidden, or :very_hidden).
|
|
1165
|
+
#
|
|
1166
|
+
# @param new_state [Symbol, String] The new state.
|
|
1167
|
+
# @return [Symbol]
|
|
1168
|
+
# @api public
|
|
1169
|
+
#: (Symbol | String new_state) -> Symbol
|
|
1170
|
+
def state=(new_state)
|
|
1171
|
+
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1172
|
+
|
|
1173
|
+
@writer.state = new_state
|
|
1174
|
+
@writer.state
|
|
1175
|
+
end
|
|
1176
|
+
|
|
837
1177
|
# Gets or sets the tab color of this worksheet.
|
|
838
1178
|
#
|
|
1179
|
+
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#tab_color=} instead.
|
|
839
1180
|
# @param spec [String, Hash, Symbol, nil] Tab color hex string or hash options.
|
|
840
1181
|
# @param opts [Hash] Color keyword arguments (e.g. theme: 1, tint: 0.5).
|
|
841
1182
|
# @return [String, Hash, nil]
|
|
@@ -846,49 +1187,96 @@ module Xlsxrb
|
|
|
846
1187
|
|
|
847
1188
|
@writer.tab_color(...)
|
|
848
1189
|
end
|
|
849
|
-
alias tab_color= tab_color
|
|
850
1190
|
|
|
851
|
-
# Sets
|
|
1191
|
+
# Sets the tab color of this worksheet.
|
|
852
1192
|
#
|
|
853
|
-
# @
|
|
854
|
-
#
|
|
1193
|
+
# @param spec [String, Hash, Symbol, nil] Tab color hex string or hash options.
|
|
1194
|
+
# @return [String, Hash, nil]
|
|
1195
|
+
# @api public
|
|
1196
|
+
#: (String | Symbol | Hash[Symbol, untyped] | nil spec) -> (String | Hash[Symbol, untyped] | nil)
|
|
1197
|
+
def tab_color=(spec)
|
|
1198
|
+
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1199
|
+
|
|
1200
|
+
@writer.tab_color = spec
|
|
1201
|
+
end
|
|
1202
|
+
|
|
1203
|
+
# Sets a single sheet property.
|
|
855
1204
|
#
|
|
856
1205
|
# @param name [Symbol, String] Property name.
|
|
857
1206
|
# @param value [Object] Property value.
|
|
858
1207
|
# @return [void]
|
|
859
1208
|
# @api public
|
|
860
1209
|
#: (Symbol | String name, untyped value) -> void
|
|
861
|
-
def
|
|
1210
|
+
def sheet_property(...)
|
|
862
1211
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
863
1212
|
|
|
864
|
-
@writer.
|
|
1213
|
+
@writer.sheet_property(...)
|
|
865
1214
|
end
|
|
866
1215
|
|
|
867
|
-
#
|
|
1216
|
+
# Sets sheet properties (e.g. tab color, page setup flags). Accepts kwargs or name/value pair.
|
|
868
1217
|
#
|
|
869
1218
|
# @example
|
|
870
|
-
# s.
|
|
1219
|
+
# s.sheet_properties(tab_color: "FF0000")
|
|
871
1220
|
#
|
|
872
|
-
# @param name [String]
|
|
1221
|
+
# @param name [Symbol, String, Hash, nil] Property name or hash.
|
|
1222
|
+
# @param value [Object, nil] Property value.
|
|
1223
|
+
# @param opts [Hash] Additional options.
|
|
1224
|
+
# @return [void]
|
|
1225
|
+
# @api public
|
|
1226
|
+
#: (?Symbol | String | Hash[Symbol, untyped] | nil name, ?untyped value, **untyped opts) -> void
|
|
1227
|
+
def sheet_properties(...)
|
|
1228
|
+
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1229
|
+
|
|
1230
|
+
@writer.sheet_properties(...)
|
|
1231
|
+
end
|
|
1232
|
+
|
|
1233
|
+
# Replaces worksheet properties.
|
|
1234
|
+
# @param opts [Hash, Elements::SheetProperties]
|
|
1235
|
+
# @return [void]
|
|
1236
|
+
# @api public
|
|
1237
|
+
#: (Hash[Symbol, untyped] | Elements::SheetProperties opts) -> void
|
|
1238
|
+
def sheet_properties=(opts)
|
|
1239
|
+
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1240
|
+
|
|
1241
|
+
@writer.sheet_properties = opts
|
|
1242
|
+
end
|
|
1243
|
+
|
|
873
1244
|
# Adds a defined name (named range or formula) scoped to this sheet or workbook.
|
|
874
1245
|
# Bare cell references and coordinate keywords are automatically formatted with sheet quotes and absolute $ references.
|
|
875
1246
|
#
|
|
876
1247
|
# @param name [String] Defined name identifier.
|
|
877
1248
|
# @param value [Object, nil] Value or formula expression.
|
|
878
1249
|
# @param hidden [Boolean] Whether the defined name is hidden.
|
|
879
|
-
# @param
|
|
1250
|
+
# @param column [Integer, String, nil] Deprecated alias for columns.
|
|
1251
|
+
# @param columns [Integer, String, nil] Column index or letter for coordinate-based reference.
|
|
1252
|
+
# @param col [Integer, String, nil] Deprecated alias for column.
|
|
1253
|
+
# @param row [Integer, Range, nil] Deprecated alias for rows.
|
|
880
1254
|
# @param rows [Integer, Range, nil] Row or row range (1-based) for coordinate-based reference.
|
|
881
1255
|
# @param range [String, nil] Cell range reference.
|
|
882
|
-
# @param sheet [String, nil]
|
|
1256
|
+
# @param sheet [String, nil] Reference sheet name (defaults to current sheet).
|
|
1257
|
+
# @param scope [String, Symbol, nil] Scope identifier (:workbook or sheet name).
|
|
1258
|
+
# @param local [Boolean] Deprecated alias for scope: :current.
|
|
883
1259
|
# @return [void]
|
|
884
1260
|
# @api public
|
|
885
|
-
#: (String name, ?untyped value, ?hidden: bool, ?col: untyped, ?rows: untyped, ?range: untyped, ?sheet: String?, ?local: bool) -> void
|
|
886
|
-
def defined_name(name, value = nil, hidden: false, col: nil, rows: nil, range: nil, sheet: nil, local: false)
|
|
1261
|
+
#: (String name, ?untyped value, ?hidden: bool, ?column: untyped, ?columns: untyped, ?col: untyped, ?row: untyped, ?rows: untyped, ?range: untyped, ?sheet: String?, ?scope: (String | Symbol)?, ?local: bool) -> void
|
|
1262
|
+
def defined_name(name, value = nil, hidden: false, column: nil, columns: nil, col: nil, row: nil, rows: nil, range: nil, sheet: nil, scope: nil, local: false)
|
|
887
1263
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
888
1264
|
|
|
1265
|
+
warn "[DEPRECATION] `col:` is deprecated; use `column:` (or `columns:`) instead.", uplevel: 1 if col
|
|
1266
|
+
warn "[DEPRECATION] `local:` is deprecated; use `scope:` instead.", uplevel: 1 if local
|
|
1267
|
+
warn "[Xlsxrb DEPRECATION] defined_name keyword column: is deprecated; use columns: instead.", uplevel: 1 unless column.nil?
|
|
1268
|
+
warn "[Xlsxrb DEPRECATION] defined_name keyword row: is deprecated; use rows: instead.", uplevel: 1 unless row.nil?
|
|
1269
|
+
c_arg = column || columns || col
|
|
1270
|
+
r_arg = row || rows
|
|
889
1271
|
ref_sheet = sheet || @sheet_name
|
|
890
|
-
local_sheet =
|
|
891
|
-
|
|
1272
|
+
local_sheet = if scope
|
|
1273
|
+
scope == :workbook ? nil : scope.to_s
|
|
1274
|
+
elsif local
|
|
1275
|
+
@sheet_name || sheet
|
|
1276
|
+
else
|
|
1277
|
+
sheet
|
|
1278
|
+
end
|
|
1279
|
+
@writer.defined_name(name, value, sheet: local_sheet, hidden: hidden, columns: c_arg, rows: r_arg, range: range, ref_sheet: ref_sheet)
|
|
892
1280
|
end
|
|
893
1281
|
|
|
894
1282
|
# Freezes rows and/or columns for scrolling.
|
|
@@ -897,47 +1285,95 @@ module Xlsxrb
|
|
|
897
1285
|
# s.freeze_pane(row: 1)
|
|
898
1286
|
#
|
|
899
1287
|
# @example Freeze first column and top 2 rows
|
|
900
|
-
# s.freeze_pane(row: 2,
|
|
1288
|
+
# s.freeze_pane(row: 2, column: 1)
|
|
901
1289
|
#
|
|
902
1290
|
# @param row [Integer, nil] Number of rows to freeze.
|
|
903
|
-
# @param
|
|
1291
|
+
# @param column [Integer, String, nil] Number of columns to freeze.
|
|
1292
|
+
# @param col [Integer, String, nil] Deprecated alias for column.
|
|
904
1293
|
# @return [void]
|
|
905
1294
|
# @api public
|
|
906
|
-
#: (?row: Integer | nil, ?col: Integer |
|
|
1295
|
+
#: (?row: Integer | nil, ?column: (Integer | String)?, ?col: (Integer | String)?) -> void
|
|
907
1296
|
def freeze_pane(...)
|
|
908
1297
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
909
1298
|
|
|
910
1299
|
@writer.freeze_pane(...)
|
|
911
1300
|
end
|
|
912
1301
|
|
|
913
|
-
#
|
|
914
|
-
# Edge case / untested delegation block
|
|
915
|
-
# Sets the print area range for the sheet.
|
|
1302
|
+
# Sets or clears freeze pane configuration.
|
|
916
1303
|
#
|
|
917
|
-
# @param
|
|
1304
|
+
# @param opts [Elements::FreezePane, Hash, nil] Freeze pane options.
|
|
918
1305
|
# @return [void]
|
|
919
1306
|
# @api public
|
|
920
|
-
#: (
|
|
921
|
-
def
|
|
1307
|
+
#: (untyped opts) -> void
|
|
1308
|
+
def freeze_pane=(opts)
|
|
922
1309
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
923
1310
|
|
|
924
|
-
@writer.
|
|
1311
|
+
@writer.freeze_pane = opts
|
|
925
1312
|
end
|
|
926
|
-
# simplecov:enable
|
|
927
1313
|
|
|
928
|
-
#
|
|
929
|
-
# Edge case / untested delegation block
|
|
930
|
-
# Configures repeating title rows and columns for printing.
|
|
1314
|
+
# Sets or gets the print area range for the sheet.
|
|
931
1315
|
#
|
|
932
|
-
# @param
|
|
933
|
-
# @
|
|
934
|
-
# @
|
|
1316
|
+
# @param range [String, Object, nil] Range reference.
|
|
1317
|
+
# @return [String, nil, void]
|
|
1318
|
+
# @api public
|
|
1319
|
+
#: (?untyped range) -> (String | nil | void)
|
|
1320
|
+
def print_area(range = OMITTED)
|
|
1321
|
+
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1322
|
+
|
|
1323
|
+
if range.equal?(OMITTED)
|
|
1324
|
+
@writer.print_area
|
|
1325
|
+
else
|
|
1326
|
+
@writer.print_area(range, sheet: @sheet_name)
|
|
1327
|
+
end
|
|
1328
|
+
end
|
|
1329
|
+
|
|
1330
|
+
# Sets the print area for this worksheet.
|
|
1331
|
+
#
|
|
1332
|
+
# @param range [String, nil] Cell range (e.g. "A1:G50").
|
|
1333
|
+
# @return [String, nil]
|
|
1334
|
+
# @api public
|
|
1335
|
+
#: (String? range) -> String?
|
|
1336
|
+
def print_area=(range)
|
|
1337
|
+
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1338
|
+
|
|
1339
|
+
@writer.print_area(range, sheet: @sheet_name)
|
|
1340
|
+
range
|
|
1341
|
+
end
|
|
1342
|
+
|
|
1343
|
+
# Configures or gets repeating title rows and columns for printing.
|
|
1344
|
+
#
|
|
1345
|
+
# @param rows [String, Integer, Range, Object, nil] Row range to repeat (e.g. "1:2").
|
|
1346
|
+
# @param columns [String, Integer, Symbol, Range, Object, nil] Column range to repeat (e.g. "A:B").
|
|
1347
|
+
# @param cols [String, Integer, Symbol, Range, Object, nil] Deprecated alias for columns.
|
|
1348
|
+
# @return [Elements::PrintTitles, nil, void]
|
|
1349
|
+
# @api public
|
|
1350
|
+
#: (?rows: untyped, ?columns: untyped, ?cols: untyped) -> (Elements::PrintTitles | nil | void)
|
|
1351
|
+
def print_titles(rows: OMITTED, columns: OMITTED, cols: OMITTED)
|
|
1352
|
+
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1353
|
+
|
|
1354
|
+
if rows.equal?(OMITTED) && columns.equal?(OMITTED) && cols.equal?(OMITTED)
|
|
1355
|
+
@writer.print_titles
|
|
1356
|
+
else
|
|
1357
|
+
@writer.print_titles(rows: rows, columns: columns, cols: cols, sheet: @sheet_name)
|
|
1358
|
+
end
|
|
1359
|
+
end
|
|
1360
|
+
|
|
1361
|
+
# Sets repeating print titles for this worksheet.
|
|
1362
|
+
#
|
|
1363
|
+
# @param opts [Elements::PrintTitles, Hash, nil] Options with :rows and/or :columns.
|
|
1364
|
+
# @return [Elements::PrintTitles, Hash, nil]
|
|
935
1365
|
# @api public
|
|
936
|
-
#: (
|
|
937
|
-
def print_titles(
|
|
1366
|
+
#: (Elements::PrintTitles | Hash[Symbol, untyped] | nil opts) -> (Elements::PrintTitles | Hash[Symbol, untyped] | nil)
|
|
1367
|
+
def print_titles=(opts)
|
|
938
1368
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
939
1369
|
|
|
940
|
-
|
|
1370
|
+
if opts.nil?
|
|
1371
|
+
@writer.print_titles = nil
|
|
1372
|
+
else
|
|
1373
|
+
h = opts.respond_to?(:to_h) ? opts.to_h : opts
|
|
1374
|
+
@writer.print_titles(**h, sheet: @sheet_name)
|
|
1375
|
+
end
|
|
1376
|
+
opts
|
|
941
1377
|
end
|
|
942
1378
|
|
|
943
1379
|
# Sets repeating title rows to appear at the top of each printed page.
|
|
@@ -969,32 +1405,49 @@ module Xlsxrb
|
|
|
969
1405
|
|
|
970
1406
|
# Splits sheet view into panes.
|
|
971
1407
|
#
|
|
972
|
-
# @param x_split [
|
|
973
|
-
# @param y_split [
|
|
1408
|
+
# @param x_split [Integer] Horizontal split position.
|
|
1409
|
+
# @param y_split [Integer] Vertical split position.
|
|
974
1410
|
# @param top_left_cell [String, nil] Top-left visible cell in bottom-right pane.
|
|
975
|
-
# @param active_pane [String, nil] Active pane identifier.
|
|
976
|
-
# @param state [String, nil] Split state.
|
|
1411
|
+
# @param active_pane [String, Symbol, nil] Active pane identifier.
|
|
1412
|
+
# @param state [String, Symbol, nil] Split state.
|
|
977
1413
|
# @return [void]
|
|
978
1414
|
# @api public
|
|
979
|
-
#: (?x_split:
|
|
1415
|
+
#: (?x_split: Integer, ?y_split: Integer, ?top_left_cell: String?, ?active_pane: (String | Symbol)?, ?state: (String | Symbol)?) -> void
|
|
980
1416
|
def split_pane(...)
|
|
981
1417
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
982
1418
|
|
|
983
1419
|
@writer.split_pane(...)
|
|
984
1420
|
end
|
|
985
1421
|
|
|
1422
|
+
# Sets or clears split pane configuration.
|
|
1423
|
+
#
|
|
1424
|
+
# @param opts [Elements::SplitPane, Hash, nil] Split pane options.
|
|
1425
|
+
# @return [void]
|
|
1426
|
+
# @api public
|
|
1427
|
+
#: (untyped opts) -> void
|
|
1428
|
+
def split_pane=(opts)
|
|
1429
|
+
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1430
|
+
|
|
1431
|
+
@writer.split_pane = opts
|
|
1432
|
+
end
|
|
1433
|
+
|
|
986
1434
|
# simplecov:disable
|
|
987
1435
|
# Edge case / untested delegation block
|
|
988
|
-
#
|
|
1436
|
+
# Sets workbook structure and window protection.
|
|
989
1437
|
#
|
|
990
1438
|
# @param opts [Hash] Protection options.
|
|
991
1439
|
# @return [void]
|
|
992
1440
|
# @api public
|
|
993
1441
|
#: (**untyped opts) -> void
|
|
994
|
-
def
|
|
995
|
-
|
|
1442
|
+
def workbook_protection(...)
|
|
1443
|
+
@writer.workbook_protection(...)
|
|
1444
|
+
end
|
|
996
1445
|
|
|
997
|
-
|
|
1446
|
+
# @deprecated Use {#workbook_protection} instead.
|
|
1447
|
+
#: (**untyped opts) -> void
|
|
1448
|
+
def protect_workbook(...)
|
|
1449
|
+
warn "[DEPRECATION] `protect_workbook` is deprecated; use `workbook_protection` instead.", uplevel: 1
|
|
1450
|
+
workbook_protection(...)
|
|
998
1451
|
end
|
|
999
1452
|
# simplecov:enable
|
|
1000
1453
|
|
|
@@ -1002,11 +1455,11 @@ module Xlsxrb
|
|
|
1002
1455
|
# Edge case / untested delegation block
|
|
1003
1456
|
# Sets core metadata property.
|
|
1004
1457
|
#
|
|
1005
|
-
# @param name [
|
|
1006
|
-
# @param value [
|
|
1458
|
+
# @param name [Symbol] Property name.
|
|
1459
|
+
# @param value [String, Integer, Time] Property value.
|
|
1007
1460
|
# @return [void]
|
|
1008
1461
|
# @api public
|
|
1009
|
-
#: (String |
|
|
1462
|
+
#: (Symbol name, String | Integer | Time value) -> void
|
|
1010
1463
|
def core_property(...)
|
|
1011
1464
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1012
1465
|
|
|
@@ -1016,25 +1469,44 @@ module Xlsxrb
|
|
|
1016
1469
|
|
|
1017
1470
|
# Sets the active/selected cell on the sheet.
|
|
1018
1471
|
#
|
|
1019
|
-
# @param active_cell [String] Cell reference (e.g. "A1").
|
|
1472
|
+
# @param active_cell [String] Cell reference (e.g. "A1") or range (e.g. "A1:D10").
|
|
1020
1473
|
# @param sqref [String, nil] Selection range.
|
|
1021
1474
|
# @param pane [String, Symbol, nil] Pane identifier.
|
|
1022
1475
|
# @return [void]
|
|
1023
1476
|
# @api public
|
|
1024
1477
|
#: (String active_cell, ?sqref: String?, ?pane: (String | Symbol)?) -> void
|
|
1025
|
-
def
|
|
1478
|
+
def selection(...)
|
|
1026
1479
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1027
1480
|
|
|
1028
|
-
@writer.
|
|
1481
|
+
@writer.selection(...)
|
|
1029
1482
|
end
|
|
1030
1483
|
|
|
1031
|
-
#
|
|
1484
|
+
# Sets or clears the selection configuration.
|
|
1032
1485
|
#
|
|
1033
|
-
# @param
|
|
1034
|
-
# @
|
|
1035
|
-
# @
|
|
1036
|
-
|
|
1037
|
-
|
|
1486
|
+
# @param opts [Elements::Selection, Array<Elements::Selection, Hash>, Hash, nil]
|
|
1487
|
+
# @return [void]
|
|
1488
|
+
# @api public
|
|
1489
|
+
#: (untyped opts) -> void
|
|
1490
|
+
def selection=(opts)
|
|
1491
|
+
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1492
|
+
|
|
1493
|
+
@writer.selection = opts
|
|
1494
|
+
end
|
|
1495
|
+
|
|
1496
|
+
# @deprecated Use {#selection} instead.
|
|
1497
|
+
#: (String active_cell, ?sqref: String?, ?pane: (String | Symbol)?) -> void
|
|
1498
|
+
def select_cell(...)
|
|
1499
|
+
warn "[DEPRECATION] `select_cell` is deprecated; use `selection` instead.", uplevel: 1
|
|
1500
|
+
selection(...)
|
|
1501
|
+
end
|
|
1502
|
+
|
|
1503
|
+
# Configures page margins for printing.
|
|
1504
|
+
#
|
|
1505
|
+
# @param left [Float, nil] Left margin in inches.
|
|
1506
|
+
# @param right [Float, nil] Right margin in inches.
|
|
1507
|
+
# @param top [Float, nil] Top margin in inches.
|
|
1508
|
+
# @param bottom [Float, nil] Bottom margin in inches.
|
|
1509
|
+
# @param header [Float, nil] Header margin in inches.
|
|
1038
1510
|
# @param footer [Float, nil] Footer margin in inches.
|
|
1039
1511
|
# @return [void]
|
|
1040
1512
|
# @api public
|
|
@@ -1045,6 +1517,18 @@ module Xlsxrb
|
|
|
1045
1517
|
@writer.page_margins(...)
|
|
1046
1518
|
end
|
|
1047
1519
|
|
|
1520
|
+
# Sets page margins configuration.
|
|
1521
|
+
#
|
|
1522
|
+
# @param opts [Hash, Elements::PageMargins, nil]
|
|
1523
|
+
# @return [void]
|
|
1524
|
+
# @api public
|
|
1525
|
+
#: (untyped opts) -> void
|
|
1526
|
+
def page_margins=(opts)
|
|
1527
|
+
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1528
|
+
|
|
1529
|
+
@writer.page_margins = opts
|
|
1530
|
+
end
|
|
1531
|
+
|
|
1048
1532
|
# Configures page orientation, paper size, and print setup.
|
|
1049
1533
|
#
|
|
1050
1534
|
# @param orientation [String, Symbol, nil] "portrait" or "landscape" (or :portrait, :landscape).
|
|
@@ -1059,6 +1543,18 @@ module Xlsxrb
|
|
|
1059
1543
|
@writer.page_setup(...)
|
|
1060
1544
|
end
|
|
1061
1545
|
|
|
1546
|
+
# Sets page setup configuration.
|
|
1547
|
+
#
|
|
1548
|
+
# @param opts [Hash, Elements::PageSetup]
|
|
1549
|
+
# @return [void]
|
|
1550
|
+
# @api public
|
|
1551
|
+
#: (untyped opts) -> void
|
|
1552
|
+
def page_setup=(opts)
|
|
1553
|
+
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1554
|
+
|
|
1555
|
+
@writer.page_setup = opts
|
|
1556
|
+
end
|
|
1557
|
+
|
|
1062
1558
|
# Configures header and footer text for printing.
|
|
1063
1559
|
#
|
|
1064
1560
|
# @param opts [Hash] Header and footer specifications.
|
|
@@ -1071,19 +1567,43 @@ module Xlsxrb
|
|
|
1071
1567
|
@writer.header_footer(...)
|
|
1072
1568
|
end
|
|
1073
1569
|
|
|
1570
|
+
# Sets header and footer configuration.
|
|
1571
|
+
#
|
|
1572
|
+
# @param opts [Hash, Elements::HeaderFooter]
|
|
1573
|
+
# @return [void]
|
|
1574
|
+
# @api public
|
|
1575
|
+
#: (untyped opts) -> void
|
|
1576
|
+
def header_footer=(opts)
|
|
1577
|
+
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1578
|
+
|
|
1579
|
+
@writer.header_footer = opts
|
|
1580
|
+
end
|
|
1581
|
+
|
|
1074
1582
|
# Configures print options (e.g. gridlines, headings).
|
|
1075
1583
|
#
|
|
1076
|
-
# @param name [Symbol, String] Print option name.
|
|
1077
|
-
# @param value [Object] Print option value.
|
|
1584
|
+
# @param name [Symbol, String, Hash, nil] Print option name or hash.
|
|
1585
|
+
# @param value [Object, nil] Print option value.
|
|
1586
|
+
# @param opts [Hash] Additional options.
|
|
1078
1587
|
# @return [void]
|
|
1079
1588
|
# @api public
|
|
1080
|
-
#: (Symbol | String name, untyped value) -> void
|
|
1589
|
+
#: (?Symbol | String | Hash[Symbol, untyped] | nil name, ?untyped value, **untyped opts) -> void
|
|
1081
1590
|
def print_options(...)
|
|
1082
1591
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1083
1592
|
|
|
1084
1593
|
@writer.print_options(...)
|
|
1085
1594
|
end
|
|
1086
1595
|
|
|
1596
|
+
# Replaces print options.
|
|
1597
|
+
# @param opts [Hash, Elements::PrintOptions]
|
|
1598
|
+
# @return [void]
|
|
1599
|
+
# @api public
|
|
1600
|
+
#: (Hash[Symbol, untyped] | Elements::PrintOptions opts) -> void
|
|
1601
|
+
def print_options=(opts)
|
|
1602
|
+
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1603
|
+
|
|
1604
|
+
@writer.print_options = opts
|
|
1605
|
+
end
|
|
1606
|
+
|
|
1087
1607
|
# simplecov:disable
|
|
1088
1608
|
# Edge case / untested delegation block
|
|
1089
1609
|
# Sets document metadata properties (core, app, custom).
|
|
@@ -1105,11 +1625,11 @@ module Xlsxrb
|
|
|
1105
1625
|
# Edge case / untested delegation block
|
|
1106
1626
|
# Sets app metadata property.
|
|
1107
1627
|
#
|
|
1108
|
-
# @param name [
|
|
1109
|
-
# @param value [
|
|
1628
|
+
# @param name [Symbol] Property name.
|
|
1629
|
+
# @param value [String, Integer, Time] Property value.
|
|
1110
1630
|
# @return [void]
|
|
1111
1631
|
# @api public
|
|
1112
|
-
#: (String |
|
|
1632
|
+
#: (Symbol name, String | Integer | Time value) -> void
|
|
1113
1633
|
def app_property(...)
|
|
1114
1634
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1115
1635
|
|
|
@@ -1117,27 +1637,47 @@ module Xlsxrb
|
|
|
1117
1637
|
end
|
|
1118
1638
|
# simplecov:enable
|
|
1119
1639
|
|
|
1120
|
-
#
|
|
1640
|
+
# Sets sheet-level protection with optional password hashing.
|
|
1121
1641
|
#
|
|
1122
1642
|
# @param opts [Hash] Protection options.
|
|
1123
1643
|
# @return [void]
|
|
1124
1644
|
# @api public
|
|
1125
1645
|
#: (**untyped opts) -> void
|
|
1126
|
-
def
|
|
1646
|
+
def sheet_protection(...)
|
|
1647
|
+
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1648
|
+
|
|
1649
|
+
@writer.sheet_protection(...)
|
|
1650
|
+
end
|
|
1651
|
+
|
|
1652
|
+
# Sets or clears sheet protection configuration.
|
|
1653
|
+
#
|
|
1654
|
+
# @param opts [Elements::SheetProtection, Hash, Boolean, nil]
|
|
1655
|
+
# @return [void]
|
|
1656
|
+
# @api public
|
|
1657
|
+
#: (untyped opts) -> void
|
|
1658
|
+
def sheet_protection=(opts)
|
|
1127
1659
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1128
1660
|
|
|
1129
|
-
@writer.
|
|
1661
|
+
@writer.sheet_protection = opts
|
|
1662
|
+
end
|
|
1663
|
+
|
|
1664
|
+
# @deprecated Use {#sheet_protection} instead.
|
|
1665
|
+
#: (**untyped opts) -> void
|
|
1666
|
+
def protect_sheet(...)
|
|
1667
|
+
warn "[DEPRECATION] `protect_sheet` is deprecated; use `sheet_protection` instead.", uplevel: 1
|
|
1668
|
+
sheet_protection(...)
|
|
1130
1669
|
end
|
|
1131
1670
|
|
|
1132
1671
|
# simplecov:disable
|
|
1133
1672
|
# Edge case / untested delegation block
|
|
1134
1673
|
# Sets custom metadata property.
|
|
1135
1674
|
#
|
|
1136
|
-
# @param name [String
|
|
1137
|
-
# @param value [
|
|
1675
|
+
# @param name [String] Property name.
|
|
1676
|
+
# @param value [String, Integer, Float, Boolean, Time] Property value.
|
|
1677
|
+
# @param type [Symbol] Value type.
|
|
1138
1678
|
# @return [void]
|
|
1139
1679
|
# @api public
|
|
1140
|
-
#: (String |
|
|
1680
|
+
#: (String name, String | Integer | Float | bool | Time value, ?type: ::Symbol) -> void
|
|
1141
1681
|
def custom_property(...)
|
|
1142
1682
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1143
1683
|
|
|
@@ -1149,14 +1689,16 @@ module Xlsxrb
|
|
|
1149
1689
|
#
|
|
1150
1690
|
# @param file_data [String] Binary image data or file content.
|
|
1151
1691
|
# @param ext [String] Image extension ("png", "jpeg", etc.).
|
|
1152
|
-
# @param
|
|
1692
|
+
# @param from_column [Integer, nil] Starting column index (0-based).
|
|
1693
|
+
# @param from_col [Integer, nil] Deprecated alias for from_column.
|
|
1153
1694
|
# @param from_row [Integer] Starting row index (0-based).
|
|
1154
|
-
# @param
|
|
1695
|
+
# @param to_column [Integer, nil] Ending column index (0-based).
|
|
1696
|
+
# @param to_col [Integer, nil] Deprecated alias for to_column.
|
|
1155
1697
|
# @param to_row [Integer] Ending row index (0-based).
|
|
1156
1698
|
# @param opts [Hash] Additional anchor and sizing options.
|
|
1157
1699
|
# @return [void]
|
|
1158
1700
|
# @api public
|
|
1159
|
-
#: (String file_data, ?ext: String, ?from_col: Integer
|
|
1701
|
+
#: (String file_data, ?ext: String, ?from_column: Integer?, ?from_col: Integer?, ?from_row: Integer, ?to_column: Integer?, ?to_col: Integer?, ?to_row: Integer, **untyped opts) -> void
|
|
1160
1702
|
def image(...)
|
|
1161
1703
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1162
1704
|
|
|
@@ -1168,6 +1710,7 @@ module Xlsxrb
|
|
|
1168
1710
|
# @example Set background image from binary data
|
|
1169
1711
|
# sheet.background_image(png_bytes, ext: "png")
|
|
1170
1712
|
#
|
|
1713
|
+
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#background_image=} instead.
|
|
1171
1714
|
# @param file_data [String, Hash, Elements::Image, nil] Image binary data, file path, or image options hash.
|
|
1172
1715
|
# @param ext [String, nil] Image extension.
|
|
1173
1716
|
# @param opts [Hash] Additional options.
|
|
@@ -1179,30 +1722,47 @@ module Xlsxrb
|
|
|
1179
1722
|
|
|
1180
1723
|
@writer.background_image(...)
|
|
1181
1724
|
end
|
|
1725
|
+
# @deprecated Use {#background_image} instead. Will be removed in 0.2.0.
|
|
1182
1726
|
alias background_picture background_image
|
|
1727
|
+
# @deprecated Use {#background_image} instead. Will be removed in 0.2.0.
|
|
1183
1728
|
alias picture background_image
|
|
1184
1729
|
|
|
1730
|
+
#: (untyped val) -> untyped
|
|
1185
1731
|
def background_image=(val)
|
|
1186
1732
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1187
1733
|
|
|
1188
1734
|
@writer.background_image = val
|
|
1189
1735
|
end
|
|
1736
|
+
# @deprecated Use {#background_image=} instead. Will be removed in 0.2.0.
|
|
1190
1737
|
alias background_picture= background_image=
|
|
1738
|
+
# @deprecated Use {#background_image=} instead. Will be removed in 0.2.0.
|
|
1191
1739
|
alias picture= background_image=
|
|
1192
1740
|
|
|
1193
1741
|
# Configures sheet view settings (zoom scale, grid lines visibility).
|
|
1194
1742
|
#
|
|
1195
|
-
# @param name [Symbol, String] View setting name.
|
|
1196
|
-
# @param value [Object] View setting value.
|
|
1743
|
+
# @param name [Symbol, String, Hash, nil] View setting name or hash.
|
|
1744
|
+
# @param value [Object, nil] View setting value.
|
|
1745
|
+
# @param opts [Hash] Additional options.
|
|
1197
1746
|
# @return [void]
|
|
1198
1747
|
# @api public
|
|
1199
|
-
#: (Symbol | String name, untyped value) -> void
|
|
1748
|
+
#: (?Symbol | String | Hash[Symbol, untyped] | nil name, ?untyped value, **untyped opts) -> void
|
|
1200
1749
|
def sheet_view(...)
|
|
1201
1750
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1202
1751
|
|
|
1203
1752
|
@writer.sheet_view(...)
|
|
1204
1753
|
end
|
|
1205
1754
|
|
|
1755
|
+
# Replaces sheet view properties.
|
|
1756
|
+
# @param opts [Hash, Elements::SheetView]
|
|
1757
|
+
# @return [void]
|
|
1758
|
+
# @api public
|
|
1759
|
+
#: (Hash[Symbol, untyped] | Elements::SheetView opts) -> void
|
|
1760
|
+
def sheet_view=(opts)
|
|
1761
|
+
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1762
|
+
|
|
1763
|
+
@writer.sheet_view = opts
|
|
1764
|
+
end
|
|
1765
|
+
|
|
1206
1766
|
# Configures sheet format properties (e.g. default_row_height, default_col_width).
|
|
1207
1767
|
#
|
|
1208
1768
|
# @param name [Symbol, String, Hash, nil] Property name or hash of properties.
|
|
@@ -1210,11 +1770,22 @@ module Xlsxrb
|
|
|
1210
1770
|
# @param opts [Hash] Keyword arguments for sheet format properties.
|
|
1211
1771
|
# @return [Hash[Symbol, untyped]]
|
|
1212
1772
|
# @api public
|
|
1213
|
-
#: (?Symbol | String | Hash[Symbol, untyped] | nil name, ?untyped value, **untyped opts) ->
|
|
1214
|
-
def sheet_format(
|
|
1773
|
+
#: (?Symbol | String | Hash[Symbol, untyped] | Elements::MetadataRecord | nil name, ?untyped value, **untyped opts) -> (Elements::SheetFormat | void)
|
|
1774
|
+
def sheet_format(name = nil, value = nil, **opts)
|
|
1215
1775
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1216
1776
|
|
|
1217
|
-
@writer.sheet_format(
|
|
1777
|
+
@writer.sheet_format(name, value, **opts)
|
|
1778
|
+
end
|
|
1779
|
+
|
|
1780
|
+
# Replaces sheet format properties.
|
|
1781
|
+
# @param opts [Hash, Elements::SheetFormat]
|
|
1782
|
+
# @return [void]
|
|
1783
|
+
# @api public
|
|
1784
|
+
#: (Hash[Symbol, untyped] | Elements::SheetFormat opts) -> void
|
|
1785
|
+
def sheet_format=(opts)
|
|
1786
|
+
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1787
|
+
|
|
1788
|
+
@writer.sheet_format = opts
|
|
1218
1789
|
end
|
|
1219
1790
|
|
|
1220
1791
|
# simplecov:disable
|
|
@@ -1225,25 +1796,39 @@ module Xlsxrb
|
|
|
1225
1796
|
# @return [void]
|
|
1226
1797
|
# @api public
|
|
1227
1798
|
#: (Integer row_index) -> void
|
|
1228
|
-
def
|
|
1799
|
+
def row_break(...)
|
|
1229
1800
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1230
1801
|
|
|
1231
|
-
@writer.
|
|
1802
|
+
@writer.row_break(...)
|
|
1803
|
+
end
|
|
1804
|
+
|
|
1805
|
+
# @deprecated Use {#row_break} instead.
|
|
1806
|
+
#: (Integer row_num) -> void
|
|
1807
|
+
def page_break_row(...)
|
|
1808
|
+
warn "[DEPRECATION] `page_break_row` is deprecated; use `row_break` instead.", uplevel: 1
|
|
1809
|
+
row_break(...)
|
|
1232
1810
|
end
|
|
1233
1811
|
# simplecov:enable
|
|
1234
1812
|
|
|
1235
1813
|
# simplecov:disable
|
|
1236
1814
|
# Edge case / untested delegation block
|
|
1237
|
-
# Adds a vertical page break after the given column
|
|
1815
|
+
# Adds a vertical page break after the given column.
|
|
1238
1816
|
#
|
|
1239
|
-
# @param
|
|
1817
|
+
# @param col [Integer, String, Symbol] 0-based column index or column letter.
|
|
1240
1818
|
# @return [void]
|
|
1241
1819
|
# @api public
|
|
1242
|
-
#: (Integer
|
|
1243
|
-
def
|
|
1820
|
+
#: (Integer | String | Symbol col) -> void
|
|
1821
|
+
def column_break(...)
|
|
1244
1822
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1245
1823
|
|
|
1246
|
-
@writer.
|
|
1824
|
+
@writer.column_break(...)
|
|
1825
|
+
end
|
|
1826
|
+
|
|
1827
|
+
# @deprecated Use {#column_break} instead.
|
|
1828
|
+
#: (Integer | String | Symbol col_index) -> void
|
|
1829
|
+
def page_break_col(...)
|
|
1830
|
+
warn "[DEPRECATION] `page_break_col` is deprecated; use `column_break` instead.", uplevel: 1
|
|
1831
|
+
column_break(...)
|
|
1247
1832
|
end
|
|
1248
1833
|
# simplecov:enable
|
|
1249
1834
|
|
|
@@ -1261,6 +1846,7 @@ module Xlsxrb
|
|
|
1261
1846
|
|
|
1262
1847
|
@writer.protected_range(...)
|
|
1263
1848
|
end
|
|
1849
|
+
# @deprecated Use {#protected_range} instead. Will be removed in 0.2.0.
|
|
1264
1850
|
alias add_protected_range protected_range
|
|
1265
1851
|
|
|
1266
1852
|
# Adds a cell watch to the sheet.
|
|
@@ -1274,6 +1860,7 @@ module Xlsxrb
|
|
|
1274
1860
|
|
|
1275
1861
|
@writer.cell_watch(...)
|
|
1276
1862
|
end
|
|
1863
|
+
# @deprecated Use {#cell_watch} instead. Will be removed in 0.2.0.
|
|
1277
1864
|
alias add_cell_watch cell_watch
|
|
1278
1865
|
|
|
1279
1866
|
# Adds an ignored error entry to the sheet.
|
|
@@ -1283,12 +1870,25 @@ module Xlsxrb
|
|
|
1283
1870
|
# @return [void]
|
|
1284
1871
|
# @api public
|
|
1285
1872
|
#: (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
|
|
1286
|
-
def
|
|
1873
|
+
def ignored_error(...)
|
|
1287
1874
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1288
1875
|
|
|
1289
|
-
@writer.
|
|
1876
|
+
@writer.ignored_error(...)
|
|
1877
|
+
end
|
|
1878
|
+
|
|
1879
|
+
# @deprecated Use {#ignored_error} instead. Will be removed in 0.2.0.
|
|
1880
|
+
#: (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
|
|
1881
|
+
def ignore_error(...)
|
|
1882
|
+
warn "[DEPRECATION] #ignore_error is deprecated; use #ignored_error instead.", uplevel: 1
|
|
1883
|
+
ignored_error(...)
|
|
1884
|
+
end
|
|
1885
|
+
|
|
1886
|
+
# @deprecated Use {#ignored_error} instead. Will be removed in 0.2.0.
|
|
1887
|
+
#: (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
|
|
1888
|
+
def add_ignored_error(...)
|
|
1889
|
+
warn "[DEPRECATION] #add_ignored_error is deprecated; use #ignored_error instead.", uplevel: 1
|
|
1890
|
+
ignored_error(...)
|
|
1290
1891
|
end
|
|
1291
|
-
alias add_ignored_error ignore_error
|
|
1292
1892
|
|
|
1293
1893
|
# Returns the ignored error entries configured for this sheet.
|
|
1294
1894
|
#
|
|
@@ -1301,62 +1901,148 @@ module Xlsxrb
|
|
|
1301
1901
|
|
|
1302
1902
|
# Gets or sets phonetic (furigana) guide properties for the sheet.
|
|
1303
1903
|
#
|
|
1904
|
+
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#phonetic_properties=} instead.
|
|
1304
1905
|
# @api public
|
|
1305
|
-
#: (?
|
|
1906
|
+
#: (?untyped spec, ?font_id: Integer?, ?type: (Symbol | String)?, ?alignment: (Symbol | String)?, **untyped opts) -> (Elements::PhoneticProperties | Hash[Symbol, untyped] | nil)
|
|
1306
1907
|
def phonetic_properties(...)
|
|
1307
1908
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1308
1909
|
|
|
1309
1910
|
@writer.phonetic_properties(...)
|
|
1310
1911
|
end
|
|
1311
|
-
|
|
1912
|
+
# @deprecated Use {#phonetic_properties} instead. Will be removed in 0.2.0.
|
|
1312
1913
|
alias phonetic_pr phonetic_properties
|
|
1313
|
-
|
|
1914
|
+
|
|
1915
|
+
# Sets phonetic (furigana) guide properties for the sheet.
|
|
1916
|
+
#
|
|
1917
|
+
# @param spec [Hash, Integer, nil] Options hash or font ID integer.
|
|
1918
|
+
# @return [Hash[Symbol, untyped], Integer, nil]
|
|
1919
|
+
# @api public
|
|
1920
|
+
#: (Hash[Symbol, untyped] | Integer | nil spec) -> (Hash[Symbol, untyped] | Integer | nil)
|
|
1921
|
+
def phonetic_properties=(spec)
|
|
1922
|
+
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1923
|
+
|
|
1924
|
+
@writer.phonetic_properties = spec
|
|
1925
|
+
end
|
|
1926
|
+
# @deprecated Use {#phonetic_properties=} instead. Will be removed in 0.2.0.
|
|
1927
|
+
alias phonetic_pr= phonetic_properties=
|
|
1314
1928
|
|
|
1315
1929
|
# Sets or gets the internal code name of the worksheet.
|
|
1316
1930
|
#
|
|
1931
|
+
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#code_name=} instead.
|
|
1317
1932
|
# @param val [String, Symbol, nil] The code name.
|
|
1318
1933
|
# @return [String, nil]
|
|
1319
1934
|
# @api public
|
|
1320
1935
|
#: (?String | Symbol | nil val) -> String?
|
|
1321
|
-
def code_name(
|
|
1936
|
+
def code_name(...)
|
|
1937
|
+
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1938
|
+
|
|
1939
|
+
@writer.code_name(...)
|
|
1940
|
+
end
|
|
1941
|
+
|
|
1942
|
+
# Sets the internal code name of the worksheet.
|
|
1943
|
+
#
|
|
1944
|
+
# @param val [String, Symbol, nil] The code name.
|
|
1945
|
+
# @return [String, nil]
|
|
1946
|
+
# @api public
|
|
1947
|
+
#: (String | Symbol | nil val) -> String?
|
|
1948
|
+
def code_name=(val)
|
|
1322
1949
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1323
1950
|
|
|
1324
|
-
@writer.code_name
|
|
1951
|
+
@writer.code_name = val
|
|
1325
1952
|
end
|
|
1326
|
-
alias code_name= code_name
|
|
1327
1953
|
|
|
1328
1954
|
# Configures whether page setup fits content to page width/height.
|
|
1329
1955
|
# When enabled, optionally sets fit_to_width and/or fit_to_height on page_setup.
|
|
1330
1956
|
#
|
|
1957
|
+
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#fit_to_page=} or {#page_setup} with :fit_to_width/:fit_to_height instead.
|
|
1331
1958
|
# @param enabled [Boolean, nil] Whether to fit to page.
|
|
1332
1959
|
# @param width [Integer, nil] Pages wide to fit to.
|
|
1333
1960
|
# @param height [Integer, nil] Pages tall to fit to.
|
|
1334
1961
|
# @return [Boolean, void]
|
|
1335
1962
|
# @api public
|
|
1336
1963
|
#: (?bool? enabled, ?width: Integer?, ?height: Integer?) -> (bool | void)
|
|
1337
|
-
def fit_to_page(enabled =
|
|
1964
|
+
def fit_to_page(enabled = OMITTED, width: nil, height: nil)
|
|
1338
1965
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1339
1966
|
|
|
1340
1967
|
@writer.fit_to_page(enabled, width: width, height: height)
|
|
1341
1968
|
end
|
|
1342
|
-
|
|
1343
|
-
|
|
1969
|
+
|
|
1970
|
+
# @deprecated Use {#fit_to_page} instead. Will be removed in 0.2.0.
|
|
1971
|
+
# @return [Boolean]
|
|
1972
|
+
# @api public
|
|
1973
|
+
#: () -> bool
|
|
1974
|
+
def fit_to_page?
|
|
1975
|
+
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1976
|
+
|
|
1977
|
+
warn "[Xlsxrb DEPRECATION] fit_to_page? is deprecated; use fit_to_page instead.", uplevel: 1
|
|
1978
|
+
@writer.fit_to_page
|
|
1979
|
+
end
|
|
1980
|
+
|
|
1981
|
+
# Sets whether page setup fits content to page width/height.
|
|
1982
|
+
#
|
|
1983
|
+
# @param enabled [Boolean, nil] Whether to fit to page.
|
|
1984
|
+
# @return [Boolean]
|
|
1985
|
+
# @api public
|
|
1986
|
+
#: (bool? enabled) -> bool?
|
|
1987
|
+
def fit_to_page=(enabled)
|
|
1988
|
+
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1989
|
+
|
|
1990
|
+
@writer.fit_to_page = enabled
|
|
1991
|
+
end
|
|
1344
1992
|
|
|
1345
1993
|
# Configures worksheet calculation properties (<sheetCalcPr>).
|
|
1346
1994
|
#
|
|
1995
|
+
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#sheet_calc_properties=} instead.
|
|
1347
1996
|
# @param spec [Hash, nil] Calculation properties hash.
|
|
1348
1997
|
# @param full_calc_on_load [Boolean, nil] Whether to recalculate when loading.
|
|
1349
1998
|
# @return [Hash, nil]
|
|
1350
1999
|
# @api public
|
|
1351
|
-
#: (?
|
|
1352
|
-
def
|
|
2000
|
+
#: (?untyped spec, ?full_calc_on_load: bool?, **untyped opts) -> (Elements::SheetCalcProperties | Hash[Symbol, untyped] | nil)
|
|
2001
|
+
def sheet_calc_properties(...)
|
|
1353
2002
|
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
1354
2003
|
|
|
1355
|
-
@writer.
|
|
2004
|
+
@writer.sheet_calc_properties(...)
|
|
2005
|
+
end
|
|
2006
|
+
|
|
2007
|
+
# Sets worksheet calculation properties (<sheetCalcPr>).
|
|
2008
|
+
#
|
|
2009
|
+
# @param spec [Hash, nil] Calculation properties hash.
|
|
2010
|
+
# @return [Hash, nil]
|
|
2011
|
+
# @api public
|
|
2012
|
+
#: (Hash[Symbol, untyped]? spec) -> Hash[Symbol, untyped]?
|
|
2013
|
+
def sheet_calc_properties=(spec)
|
|
2014
|
+
raise Error, "Sheet '#{@sheet_name}' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
|
|
2015
|
+
|
|
2016
|
+
@writer.sheet_calc_properties = spec
|
|
2017
|
+
end
|
|
2018
|
+
|
|
2019
|
+
# @deprecated Use {#sheet_calc_properties} instead. Will be removed in 0.2.0.
|
|
2020
|
+
#: (?Hash[Symbol, untyped]? spec, ?full_calc_on_load: bool?, **untyped opts) -> (Elements::SheetCalcProperties | Hash[Symbol, untyped] | nil)
|
|
2021
|
+
def sheet_calc_pr(...)
|
|
2022
|
+
warn "[DEPRECATION] #sheet_calc_pr is deprecated; use #sheet_calc_properties instead.", uplevel: 1
|
|
2023
|
+
sheet_calc_properties(...)
|
|
2024
|
+
end
|
|
2025
|
+
|
|
2026
|
+
# @deprecated Use {#sheet_calc_properties} instead. Will be removed in 0.2.0.
|
|
2027
|
+
#: (?Hash[Symbol, untyped]? spec, ?full_calc_on_load: bool?, **untyped opts) -> (Elements::SheetCalcProperties | Hash[Symbol, untyped] | nil)
|
|
2028
|
+
def calc_pr(...)
|
|
2029
|
+
warn "[DEPRECATION] #calc_pr is deprecated; use #sheet_calc_properties instead.", uplevel: 1
|
|
2030
|
+
sheet_calc_properties(...)
|
|
2031
|
+
end
|
|
2032
|
+
|
|
2033
|
+
# @deprecated Use {#sheet_calc_properties=} instead. Will be removed in 0.2.0.
|
|
2034
|
+
#: (Hash[Symbol, untyped]? spec) -> Hash[Symbol, untyped]?
|
|
2035
|
+
def sheet_calc_pr=(spec)
|
|
2036
|
+
warn "[DEPRECATION] #sheet_calc_pr= is deprecated; use #sheet_calc_properties= instead.", uplevel: 1
|
|
2037
|
+
self.sheet_calc_properties = spec
|
|
2038
|
+
end
|
|
2039
|
+
|
|
2040
|
+
# @deprecated Use {#sheet_calc_properties=} instead. Will be removed in 0.2.0.
|
|
2041
|
+
#: (Hash[Symbol, untyped]? spec) -> Hash[Symbol, untyped]?
|
|
2042
|
+
def calc_pr=(spec)
|
|
2043
|
+
warn "[DEPRECATION] #calc_pr= is deprecated; use #sheet_calc_properties= instead.", uplevel: 1
|
|
2044
|
+
self.sheet_calc_properties = spec
|
|
1356
2045
|
end
|
|
1357
|
-
alias sheet_calc_pr= sheet_calc_pr
|
|
1358
|
-
alias calc_pr sheet_calc_pr
|
|
1359
|
-
alias calc_pr= sheet_calc_pr
|
|
1360
2046
|
end
|
|
1361
2047
|
|
|
1362
2048
|
# Returns the list of worksheet names created in this workbook so far.
|
|
@@ -1373,17 +2059,21 @@ module Xlsxrb
|
|
|
1373
2059
|
# Adds a new sheet to the workbook and starts streaming rows into it.
|
|
1374
2060
|
#
|
|
1375
2061
|
# @param name [String, nil] Sheet name (max 31 characters).
|
|
2062
|
+
# @param state [Symbol, String, nil] Sheet visibility state (:visible, :hidden, :very_hidden).
|
|
2063
|
+
# @param tab_color [String, Hash, nil] Tab color hex string or color hash.
|
|
2064
|
+
# @param code_name [String, nil] VBA code name.
|
|
2065
|
+
# @param hidden [Boolean, nil] Deprecated alias for state: :hidden.
|
|
1376
2066
|
# @param opts [Hash] Sheet-level configuration.
|
|
1377
2067
|
# @yield [sheet_proxy]
|
|
1378
2068
|
# @yieldparam sheet_proxy [WorksheetProxy] The streaming sheet proxy.
|
|
1379
2069
|
# @return [String] The sheet name.
|
|
1380
2070
|
# @api public
|
|
1381
|
-
#: (?String? name, **untyped opts) ?{ (WorksheetProxy) -> void } ->
|
|
1382
|
-
def sheet(name = nil, **opts)
|
|
2071
|
+
#: (?String? name, ?state: (Symbol | String)?, ?tab_color: untyped, ?code_name: String?, ?hidden: bool?, **untyped opts) ?{ (WorksheetProxy) -> void } -> String
|
|
2072
|
+
def sheet(name = nil, state: nil, tab_color: nil, code_name: nil, hidden: nil, **opts)
|
|
1383
2073
|
sheet_count = @sheets.size + (@current_sheet ? 1 : 0)
|
|
1384
2074
|
name ||= "Sheet#{sheet_count + 1}"
|
|
1385
2075
|
raise ArgumentError, "Sheet name '#{name}' must be <= 31 characters (Excel limitation)" if @strict_excel_mode && name.length > 31
|
|
1386
|
-
raise ArgumentError, "Sheet name '#{name}' contains invalid characters (Excel limitation)" if name.match?(Elements::Worksheet
|
|
2076
|
+
raise ArgumentError, "Sheet name '#{name}' contains invalid characters (Excel limitation)" if name.match?(Elements::Worksheet.forbidden_name_chars)
|
|
1387
2077
|
raise ArgumentError, "Sheet name '#{name}' cannot start or end with an apostrophe (Excel limitation)" if @strict_excel_mode && (name.start_with?("'") || name.end_with?("'"))
|
|
1388
2078
|
raise ArgumentError, "Sheet name '#{name}' is reserved by Excel (Excel limitation)" if @strict_excel_mode && name.casecmp?("History")
|
|
1389
2079
|
|
|
@@ -1392,8 +2082,12 @@ module Xlsxrb
|
|
|
1392
2082
|
raise ArgumentError, "Sheet name '#{name}' is already used. Excel requires unique sheet names." if @strict_excel_mode && existing_names.include?(name.downcase)
|
|
1393
2083
|
|
|
1394
2084
|
active = opts.delete(:active)
|
|
1395
|
-
state = opts.delete(:state)
|
|
1396
|
-
hidden = opts.delete(:hidden)
|
|
2085
|
+
state = opts.delete(:state) if opts.key?(:state)
|
|
2086
|
+
hidden = opts.delete(:hidden) if opts.key?(:hidden)
|
|
2087
|
+
code_name = opts.delete(:code_name) if opts.key?(:code_name)
|
|
2088
|
+
tab_color = opts.delete(:tab_color) if opts.key?(:tab_color)
|
|
2089
|
+
|
|
2090
|
+
warn "[Xlsxrb DEPRECATION] sheet keyword hidden: is deprecated; use state: :hidden instead.", uplevel: 1 unless hidden.nil?
|
|
1397
2091
|
state ||= :hidden if hidden
|
|
1398
2092
|
state ||= :visible
|
|
1399
2093
|
state = state.to_sym
|
|
@@ -1404,13 +2098,38 @@ module Xlsxrb
|
|
|
1404
2098
|
@active_sheet = name
|
|
1405
2099
|
@current_sheet_view[:tab_selected] = true
|
|
1406
2100
|
end
|
|
2101
|
+
self.tab_color = tab_color if tab_color
|
|
2102
|
+
self.code_name = code_name if code_name
|
|
1407
2103
|
opts.each { |k, v| sheet_properties(k, v) }
|
|
1408
2104
|
|
|
1409
2105
|
yield WorksheetProxy.new(self, @current_sheet) if block_given?
|
|
1410
2106
|
@current_sheet
|
|
1411
2107
|
end
|
|
1412
2108
|
|
|
2109
|
+
# Returns a WorksheetProxy for the current or named sheet.
|
|
2110
|
+
#
|
|
2111
|
+
# @param name_or_index [String, Symbol, Integer, nil] Sheet name or 0-based sheet index.
|
|
2112
|
+
# @yield [proxy]
|
|
2113
|
+
# @yieldparam proxy [WorksheetProxy]
|
|
2114
|
+
# @return [WorksheetProxy]
|
|
2115
|
+
# @api public
|
|
2116
|
+
#: (?String | Symbol | Integer | nil name_or_index) ?{ (WorksheetProxy) -> void } -> WorksheetProxy
|
|
2117
|
+
def [](name_or_index = nil)
|
|
2118
|
+
target_name = if name_or_index.nil?
|
|
2119
|
+
@current_sheet || sheet
|
|
2120
|
+
elsif name_or_index.is_a?(Integer)
|
|
2121
|
+
all_names = sheet_names
|
|
2122
|
+
all_names[name_or_index] || raise(ArgumentError, "Sheet index #{name_or_index} out of bounds")
|
|
2123
|
+
else
|
|
2124
|
+
name_or_index.to_s
|
|
2125
|
+
end
|
|
2126
|
+
proxy = WorksheetProxy.new(self, target_name)
|
|
2127
|
+
yield proxy if block_given?
|
|
2128
|
+
proxy
|
|
2129
|
+
end
|
|
2130
|
+
|
|
1413
2131
|
# Internal: Start or switch to a named sheet (internal helper).
|
|
2132
|
+
# @api private
|
|
1414
2133
|
#: (?String? name, ?state: Symbol) ?{ (WorksheetProxy) -> void } -> (WorksheetProxy | nil)
|
|
1415
2134
|
def internal_sheet_setup(name = nil, state: :visible)
|
|
1416
2135
|
flush_current_sheet
|
|
@@ -1461,6 +2180,8 @@ module Xlsxrb
|
|
|
1461
2180
|
@current_phonetic_properties = nil
|
|
1462
2181
|
@current_sheet_calc_pr = nil
|
|
1463
2182
|
@current_background_image = nil
|
|
2183
|
+
@current_print_area = nil
|
|
2184
|
+
@current_print_titles = nil
|
|
1464
2185
|
@current_row_outline_level = nil
|
|
1465
2186
|
@current_row_collapsed = false
|
|
1466
2187
|
@current_row_hidden = false
|
|
@@ -1475,6 +2196,8 @@ module Xlsxrb
|
|
|
1475
2196
|
# simplecov:enable
|
|
1476
2197
|
end
|
|
1477
2198
|
|
|
2199
|
+
# @api private
|
|
2200
|
+
#: () -> void
|
|
1478
2201
|
def start_sheet_entry
|
|
1479
2202
|
return if @sheet_entry_started
|
|
1480
2203
|
|
|
@@ -1516,24 +2239,36 @@ module Xlsxrb
|
|
|
1516
2239
|
# Appends a row of values to the active sheet.
|
|
1517
2240
|
#
|
|
1518
2241
|
# @param values [Array<Object>, Hash] The cell values.
|
|
1519
|
-
# @param
|
|
2242
|
+
# @param cell_styles [String, Symbol, Array, Hash, nil] Style names or inline style definitions to apply to cells.
|
|
2243
|
+
# @param row_style [Integer, Symbol, String, Hash, nil] Row style format or index.
|
|
1520
2244
|
# @param height [Float, Integer, nil] The row height in points (0 - 409).
|
|
1521
2245
|
# @param hidden [Boolean] Whether the row is hidden.
|
|
1522
2246
|
# @param custom_height [Boolean] Whether custom row height is set.
|
|
1523
2247
|
# @param outline_level [Integer, nil] Grouping/outline level (0 - 7).
|
|
1524
|
-
# @param
|
|
2248
|
+
# @param collapsed [Boolean] Whether the row is collapsed.
|
|
2249
|
+
# @param styles [String, Symbol, Array, Hash, nil] Deprecated. Use cell_styles: instead.
|
|
2250
|
+
# @param style [Integer, Symbol, String, Hash, nil] Deprecated. Use row_style: instead.
|
|
1525
2251
|
# @return [void]
|
|
1526
2252
|
# @api public
|
|
1527
|
-
#: (Array[untyped] | Hash[untyped, untyped] values, ?styles: untyped, ?height: Float | Integer | nil, ?hidden: bool, ?custom_height: bool, ?collapsed: bool, ?outline_level: Integer | nil
|
|
1528
|
-
def row(values, styles: nil, height: nil, hidden: false, custom_height: false, collapsed: false, outline_level: nil
|
|
2253
|
+
#: (Array[untyped] | Hash[untyped, untyped] values, ?cell_styles: untyped, ?row_style: untyped, ?styles: untyped, ?style: untyped, ?height: Float | Integer | nil, ?hidden: bool, ?custom_height: bool, ?collapsed: bool, ?outline_level: Integer | nil) -> void
|
|
2254
|
+
def row(values, cell_styles: nil, row_style: nil, styles: nil, style: nil, height: nil, hidden: false, custom_height: false, collapsed: false, outline_level: nil)
|
|
1529
2255
|
sheet if @current_sheet.nil?
|
|
1530
2256
|
|
|
2257
|
+
if styles
|
|
2258
|
+
warn "[DEPRECATION] StreamWriter#row keyword :styles is deprecated; use :cell_styles instead.", uplevel: 1
|
|
2259
|
+
cell_styles ||= styles
|
|
2260
|
+
end
|
|
2261
|
+
if style
|
|
2262
|
+
warn "[DEPRECATION] StreamWriter#row keyword :style is deprecated; use :row_style instead.", uplevel: 1
|
|
2263
|
+
row_style ||= style
|
|
2264
|
+
end
|
|
2265
|
+
|
|
1531
2266
|
row_index = @current_row_index
|
|
1532
2267
|
DslHelpers.validate_row_bounds!(row_index, height, strict_excel_mode: @strict_excel_mode)
|
|
1533
2268
|
@current_row_index += 1
|
|
1534
2269
|
|
|
1535
2270
|
values = DslHelpers.normalize_row_values(values)
|
|
1536
|
-
|
|
2271
|
+
cell_styles = DslHelpers.normalize_row_styles(cell_styles)
|
|
1537
2272
|
|
|
1538
2273
|
if @current_charts && !@current_charts.empty?
|
|
1539
2274
|
@current_cells ||= {}
|
|
@@ -1541,19 +2276,19 @@ module Xlsxrb
|
|
|
1541
2276
|
values.each_with_index do |val, col_idx|
|
|
1542
2277
|
next if val.nil?
|
|
1543
2278
|
|
|
1544
|
-
addr = "#{Elements::Cell.
|
|
2279
|
+
addr = "#{Elements::Cell._column_letter(col_idx)}#{row_num}"
|
|
1545
2280
|
@current_cells[addr] = val
|
|
1546
2281
|
end
|
|
1547
2282
|
end
|
|
1548
2283
|
|
|
1549
2284
|
raise ArgumentError, "Row contains #{values.length} columns, exceeding Excel limit of 16_384 columns" if @strict_excel_mode && values.length > 16_384
|
|
1550
2285
|
|
|
1551
|
-
row_style_id = if
|
|
1552
|
-
inline_name = "__inline_row_#{
|
|
1553
|
-
style(inline_name, **
|
|
2286
|
+
row_style_id = if row_style.is_a?(Hash)
|
|
2287
|
+
inline_name = "__inline_row_#{row_style.hash}"
|
|
2288
|
+
self.style(inline_name, **row_style) unless @style_name_to_id.key?(inline_name)
|
|
1554
2289
|
@style_name_to_id[inline_name]
|
|
1555
2290
|
else
|
|
1556
|
-
|
|
2291
|
+
row_style
|
|
1557
2292
|
end
|
|
1558
2293
|
|
|
1559
2294
|
effective_outline = outline_level || @current_row_outline_level
|
|
@@ -1571,9 +2306,10 @@ module Xlsxrb
|
|
|
1571
2306
|
attrs[:style_index] = row_style_id if row_style_id
|
|
1572
2307
|
end
|
|
1573
2308
|
|
|
1574
|
-
@current_row_writer.write_row_values(row_index, values, styles:
|
|
2309
|
+
@current_row_writer.write_row_values(row_index, values, styles: cell_styles, style_map: @style_name_to_id, sst: @sst, sst_index: @sst_index, attrs: attrs)
|
|
1575
2310
|
start_sheet_entry if !@sheet_entry_started && @current_row_buffer.bytesize >= 65_536
|
|
1576
2311
|
end
|
|
2312
|
+
# @deprecated Use {#row} instead. Will be removed in 0.2.0.
|
|
1577
2313
|
alias add_row row
|
|
1578
2314
|
|
|
1579
2315
|
# Appends a row to the worksheet and returns self for chaining.
|
|
@@ -1608,19 +2344,23 @@ module Xlsxrb
|
|
|
1608
2344
|
sheet if @current_sheet.nil?
|
|
1609
2345
|
@current_row_index += count
|
|
1610
2346
|
end
|
|
2347
|
+
# @deprecated Use {#skip_rows} instead. Will be removed in 0.2.0.
|
|
1611
2348
|
alias skip_row skip_rows
|
|
1612
2349
|
|
|
1613
2350
|
# Sets column formatting and properties for one or multiple columns.
|
|
1614
2351
|
#
|
|
1615
|
-
# @param index [Integer, String, Range, Array] Column index (0-based)
|
|
2352
|
+
# @param index [Integer, String, Symbol, Range, Array] Column index (0-based), letter ("A", :A), range, or array.
|
|
1616
2353
|
# @param width [Float, Integer, nil] Column width in character units (0 - 255).
|
|
1617
2354
|
# @param hidden [Boolean] Whether the column is hidden.
|
|
2355
|
+
# @param custom_width [Boolean] Whether custom width flag is set.
|
|
2356
|
+
# @param outline_level [Integer, nil] Grouping/outline level.
|
|
1618
2357
|
# @param collapsed [Boolean] Whether the column is collapsed.
|
|
1619
2358
|
# @param style [Integer, Symbol, String, Hash, nil] Column style format or index.
|
|
2359
|
+
# @param best_fit [Boolean] Whether the column automatically fits content.
|
|
1620
2360
|
# @return [void]
|
|
1621
2361
|
# @api public
|
|
1622
|
-
#: (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
|
|
1623
|
-
def column(index, width: nil, hidden: false, custom_width: false, outline_level: nil, collapsed: false, style: nil)
|
|
2362
|
+
#: (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
|
|
2363
|
+
def column(index, width: nil, hidden: false, custom_width: false, outline_level: nil, collapsed: false, style: nil, best_fit: false)
|
|
1624
2364
|
raise ArgumentError, "Column width #{width} must be between 0 and 255 characters (Excel limitation)" if @strict_excel_mode && width && (width.negative? || width > 255)
|
|
1625
2365
|
|
|
1626
2366
|
sheet if @current_sheet.nil?
|
|
@@ -1642,6 +2382,7 @@ module Xlsxrb
|
|
|
1642
2382
|
existing[:hidden] = hidden if hidden
|
|
1643
2383
|
existing[:outline_level] = outline_level unless outline_level.nil?
|
|
1644
2384
|
existing[:collapsed] = true if collapsed
|
|
2385
|
+
existing[:best_fit] = true if best_fit
|
|
1645
2386
|
if style_id
|
|
1646
2387
|
existing[:style] = style_id
|
|
1647
2388
|
@current_row_writer&.set_column_style(idx, style_id)
|
|
@@ -1649,6 +2390,7 @@ module Xlsxrb
|
|
|
1649
2390
|
else
|
|
1650
2391
|
entry = { index: idx, width: width, hidden: hidden, custom_width: custom_width || !width.nil?, outline_level: outline_level }
|
|
1651
2392
|
entry[:collapsed] = true if collapsed
|
|
2393
|
+
entry[:best_fit] = true if best_fit
|
|
1652
2394
|
if style_id
|
|
1653
2395
|
entry[:style] = style_id
|
|
1654
2396
|
@current_row_writer&.set_column_style(idx, style_id)
|
|
@@ -1657,6 +2399,36 @@ module Xlsxrb
|
|
|
1657
2399
|
end
|
|
1658
2400
|
end
|
|
1659
2401
|
@current_columns.sort_by! { |c| c[:index] }
|
|
2402
|
+
nil
|
|
2403
|
+
end
|
|
2404
|
+
|
|
2405
|
+
# Returns column configurations defined for the current worksheet.
|
|
2406
|
+
#
|
|
2407
|
+
# @return [Array<Elements::Column>]
|
|
2408
|
+
# @api public
|
|
2409
|
+
#: () -> Array[Elements::Column]
|
|
2410
|
+
def columns
|
|
2411
|
+
sheet if @current_sheet.nil?
|
|
2412
|
+
@current_columns.map do |c|
|
|
2413
|
+
if c.is_a?(Elements::Column)
|
|
2414
|
+
c
|
|
2415
|
+
else
|
|
2416
|
+
idx = c[:index]
|
|
2417
|
+
style_idx = c[:style] || c[:style_index]
|
|
2418
|
+
unmapped = c.except(:index, :width, :hidden, :custom_width, :outline_level, :style, :style_index)
|
|
2419
|
+
unmapped[:collapsed] = true if c[:collapsed]
|
|
2420
|
+
unmapped[:best_fit] = true if c[:best_fit]
|
|
2421
|
+
Elements::Column.new(
|
|
2422
|
+
index: idx,
|
|
2423
|
+
width: c[:width],
|
|
2424
|
+
hidden: c[:hidden] ? true : false,
|
|
2425
|
+
custom_width: c[:custom_width] ? true : false,
|
|
2426
|
+
outline_level: c[:outline_level],
|
|
2427
|
+
style_index: style_idx,
|
|
2428
|
+
unmapped_data: unmapped
|
|
2429
|
+
)
|
|
2430
|
+
end
|
|
2431
|
+
end
|
|
1660
2432
|
end
|
|
1661
2433
|
|
|
1662
2434
|
# Groups multiple columns together with outline hierarchy.
|
|
@@ -1679,8 +2451,11 @@ module Xlsxrb
|
|
|
1679
2451
|
def group_columns(index, level: 1, collapsed: false, hidden: false, width: nil, style: nil)
|
|
1680
2452
|
column(index, outline_level: level, collapsed: collapsed, hidden: hidden, width: width, style: style)
|
|
1681
2453
|
end
|
|
2454
|
+
# @deprecated Use {#group_columns} instead. Will be removed in 0.2.0.
|
|
1682
2455
|
alias group_column group_columns
|
|
2456
|
+
# @deprecated Use {#group_columns} instead. Will be removed in 0.2.0.
|
|
1683
2457
|
alias group_cols group_columns
|
|
2458
|
+
# @deprecated Use {#group_columns} instead. Will be removed in 0.2.0.
|
|
1684
2459
|
alias group_col group_columns
|
|
1685
2460
|
|
|
1686
2461
|
# Groups multiple rows with outline hierarchy with a block.
|
|
@@ -1717,6 +2492,7 @@ module Xlsxrb
|
|
|
1717
2492
|
@current_row_hidden = prev_hidden
|
|
1718
2493
|
end
|
|
1719
2494
|
end
|
|
2495
|
+
# @deprecated Use {#group_rows} instead. Will be removed in 0.2.0.
|
|
1720
2496
|
alias group_row group_rows
|
|
1721
2497
|
|
|
1722
2498
|
# Configures worksheet-level outline and grouping view properties.
|
|
@@ -1727,15 +2503,17 @@ module Xlsxrb
|
|
|
1727
2503
|
# @param summary_below [Boolean, nil] Flag indicating if summary rows appear below detail rows.
|
|
1728
2504
|
# @param summary_right [Boolean, nil] Flag indicating if summary columns appear to the right of detail columns.
|
|
1729
2505
|
# @param show_outline_symbols [Boolean, nil] Flag indicating whether outline symbols are visible.
|
|
1730
|
-
# @param show_symbols [Boolean, nil]
|
|
2506
|
+
# @param show_symbols [Boolean, nil] Deprecated alias for show_outline_symbols.
|
|
1731
2507
|
# @param apply_styles [Boolean, nil] Flag indicating whether automatic styles apply to outlines.
|
|
1732
2508
|
# @param opts [Hash] Additional options.
|
|
1733
|
-
# @return [Hash]
|
|
2509
|
+
# @return [Hash<Symbol, untyped>, void]
|
|
1734
2510
|
# @api public
|
|
1735
|
-
#: (?summary_below: bool?, ?summary_right: bool?, ?show_outline_symbols: bool?, ?show_symbols: bool?, ?apply_styles: bool?, **untyped opts) -> Hash[Symbol, untyped]
|
|
2511
|
+
#: (?summary_below: bool?, ?summary_right: bool?, ?show_outline_symbols: bool?, ?show_symbols: bool?, ?apply_styles: bool?, **untyped opts) -> (Hash[Symbol, untyped] | void)
|
|
1736
2512
|
def outline_properties(summary_below: nil, summary_right: nil, show_outline_symbols: nil, show_symbols: nil, apply_styles: nil, **opts)
|
|
1737
2513
|
sheet if @current_sheet.nil?
|
|
2514
|
+
return @current_sheet_properties.slice(:summary_below, :summary_right, :show_outline_symbols, :apply_styles) if summary_below.nil? && summary_right.nil? && show_outline_symbols.nil? && show_symbols.nil? && apply_styles.nil? && opts.empty?
|
|
1738
2515
|
|
|
2516
|
+
warn "[Xlsxrb DEPRECATION] outline_properties keyword show_symbols: is deprecated; use show_outline_symbols: instead.", uplevel: 1 unless show_symbols.nil?
|
|
1739
2517
|
props = (@current_sheet_properties[:outline_properties] || {}).dup
|
|
1740
2518
|
props[:summary_below] = summary_below unless summary_below.nil?
|
|
1741
2519
|
props[:summary_right] = summary_right unless summary_right.nil?
|
|
@@ -1746,28 +2524,46 @@ module Xlsxrb
|
|
|
1746
2524
|
@current_sheet_properties[:outline_properties] = props
|
|
1747
2525
|
@current_sheet_properties[:summary_below] = props[:summary_below] unless props[:summary_below].nil?
|
|
1748
2526
|
@current_sheet_properties[:summary_right] = props[:summary_right] unless props[:summary_right].nil?
|
|
1749
|
-
|
|
2527
|
+
nil
|
|
1750
2528
|
end
|
|
2529
|
+
# @deprecated Use {#outline_properties} instead. Will be removed in 0.2.0.
|
|
1751
2530
|
alias outline_pr outline_properties
|
|
1752
2531
|
|
|
2532
|
+
# Sets worksheet outline and grouping view properties.
|
|
2533
|
+
#
|
|
2534
|
+
# @param opts [Hash] Outline properties.
|
|
2535
|
+
# @return [void]
|
|
2536
|
+
# @api public
|
|
2537
|
+
#: (Hash[Symbol, untyped] opts) -> void
|
|
2538
|
+
def outline_properties=(opts)
|
|
2539
|
+
h = opts.respond_to?(:to_h) ? opts.to_h : (opts || {})
|
|
2540
|
+
outline_properties(**h)
|
|
2541
|
+
nil
|
|
2542
|
+
end
|
|
2543
|
+
alias outline_pr= outline_properties=
|
|
2544
|
+
|
|
1753
2545
|
# Adds a chart to the current worksheet.
|
|
1754
2546
|
#
|
|
2547
|
+
# @param type [Symbol, String, nil] Optional chart type (e.g. :bar, :line).
|
|
1755
2548
|
# @param options [Hash] Chart options.
|
|
1756
2549
|
# @yield [builder]
|
|
1757
2550
|
# @yieldparam builder [Xlsxrb::ChartBuilder]
|
|
1758
2551
|
# @return [void]
|
|
1759
2552
|
# @api public
|
|
1760
|
-
#: (**untyped options) ?{ (ChartBuilder) -> void } -> void
|
|
1761
|
-
def chart(**options)
|
|
2553
|
+
#: (?Symbol | String? type, **untyped options) ?{ (ChartBuilder) -> void } -> void
|
|
2554
|
+
def chart(type = nil, **options)
|
|
1762
2555
|
sheet if @current_sheet.nil?
|
|
1763
2556
|
|
|
2557
|
+
options = options.merge(type: type) if type
|
|
1764
2558
|
if block_given?
|
|
1765
2559
|
builder = ChartBuilder.new
|
|
2560
|
+
builder.type(type) if type
|
|
1766
2561
|
yield builder
|
|
1767
2562
|
options = builder.options.merge(options)
|
|
1768
2563
|
end
|
|
1769
2564
|
|
|
1770
2565
|
@current_charts << options
|
|
2566
|
+
nil
|
|
1771
2567
|
end
|
|
1772
2568
|
|
|
1773
2569
|
# Adds a hyperlink on a cell.
|
|
@@ -1801,13 +2597,25 @@ module Xlsxrb
|
|
|
1801
2597
|
|
|
1802
2598
|
# Sets the auto-filter range on the active sheet.
|
|
1803
2599
|
#
|
|
1804
|
-
# @param range [String] Cell range (e.g. "A1:E100").
|
|
2600
|
+
# @param range [String, nil] Cell range (e.g. "A1:E100").
|
|
1805
2601
|
# @return [void]
|
|
1806
2602
|
# @api public
|
|
1807
|
-
#: (String range) -> void
|
|
2603
|
+
#: (String? range) -> void
|
|
1808
2604
|
def auto_filter(range)
|
|
1809
2605
|
sheet if @current_sheet.nil?
|
|
1810
2606
|
@current_auto_filter = range
|
|
2607
|
+
nil
|
|
2608
|
+
end
|
|
2609
|
+
|
|
2610
|
+
# Sets the auto-filter range for the current worksheet.
|
|
2611
|
+
#
|
|
2612
|
+
# @param range [String, nil] Cell range (e.g. "A1:E100").
|
|
2613
|
+
# @return [String, nil]
|
|
2614
|
+
# @api public
|
|
2615
|
+
#: (String? range) -> String?
|
|
2616
|
+
def auto_filter=(range)
|
|
2617
|
+
auto_filter(range)
|
|
2618
|
+
range
|
|
1811
2619
|
end
|
|
1812
2620
|
|
|
1813
2621
|
# Sets filter criteria on a column in the auto-filter.
|
|
@@ -1816,10 +2624,18 @@ module Xlsxrb
|
|
|
1816
2624
|
# @param filter [Hash] Filter criteria.
|
|
1817
2625
|
# @return [void]
|
|
1818
2626
|
# @api public
|
|
1819
|
-
|
|
2627
|
+
# Sets filter criteria on an auto-filter column.
|
|
2628
|
+
#
|
|
2629
|
+
# @param col_id [Integer, String, Symbol] 0-based column index relative to auto-filter or column letter ("A", :B).
|
|
2630
|
+
# @param filter [Hash] Filter definition.
|
|
2631
|
+
# @return [void]
|
|
2632
|
+
# @api public
|
|
2633
|
+
#: (Integer | String | Symbol col_id, Hash[untyped, untyped] filter) -> void
|
|
1820
2634
|
def filter_column(col_id, filter)
|
|
1821
2635
|
sheet if @current_sheet.nil?
|
|
2636
|
+
col_id = Elements::Cell._column_index(col_id) if col_id.is_a?(String) || col_id.is_a?(Symbol)
|
|
1822
2637
|
@current_filter_columns[col_id] = filter
|
|
2638
|
+
nil
|
|
1823
2639
|
end
|
|
1824
2640
|
|
|
1825
2641
|
# Configures column sort state on the active sheet.
|
|
@@ -1827,28 +2643,55 @@ module Xlsxrb
|
|
|
1827
2643
|
# @param ref [String] The sorted range.
|
|
1828
2644
|
# @param sort_conditions [Array<Hash>] Sort conditions.
|
|
1829
2645
|
# @param opts [Hash] Additional options.
|
|
1830
|
-
# @return [void]
|
|
2646
|
+
# @return [Elements::SortState, Hash<Symbol, untyped>, nil, void]
|
|
1831
2647
|
# @api public
|
|
1832
|
-
#: (
|
|
1833
|
-
def sort_state(ref, sort_conditions, **opts)
|
|
2648
|
+
#: (?String? ref, ?Array[Hash[untyped, untyped]]? sort_conditions, **untyped opts) -> (untyped | void)
|
|
2649
|
+
def sort_state(ref = nil, sort_conditions = nil, **opts)
|
|
1834
2650
|
sheet if @current_sheet.nil?
|
|
2651
|
+
if ref.nil? && sort_conditions.nil? && opts.empty?
|
|
2652
|
+
return nil unless @current_sort_state
|
|
2653
|
+
return Elements::SortState.new(**@current_sort_state) if defined?(Elements::SortState)
|
|
2654
|
+
|
|
2655
|
+
return @current_sort_state
|
|
2656
|
+
end
|
|
2657
|
+
|
|
1835
2658
|
@current_sort_state = { ref: ref, sort_conditions: sort_conditions }.merge(opts)
|
|
2659
|
+
nil
|
|
2660
|
+
end
|
|
2661
|
+
|
|
2662
|
+
# Sets column sort state for the sheet.
|
|
2663
|
+
#
|
|
2664
|
+
# @param opts [Elements::SortState, Hash, nil] Sort state options.
|
|
2665
|
+
# @return [void]
|
|
2666
|
+
# @api public
|
|
2667
|
+
#: (untyped opts) -> void
|
|
2668
|
+
def sort_state=(opts)
|
|
2669
|
+
sheet if @current_sheet.nil?
|
|
2670
|
+
@current_sort_state = opts&.respond_to?(:to_h) ? opts.to_h : opts
|
|
2671
|
+
nil
|
|
1836
2672
|
end
|
|
1837
2673
|
|
|
1838
2674
|
# Adds a data validation rule.
|
|
1839
2675
|
#
|
|
1840
2676
|
# @param sqref [String, nil] Cell range.
|
|
1841
|
-
# @param opts [Hash] Validation options (or coordinate keywords: `columns:`, `rows:`, `except_rows:`, `in:`).
|
|
2677
|
+
# @param opts [Hash] Validation options (or coordinate keywords: `columns:`, `rows:`, `except_rows:`, `list:`, `in:`).
|
|
1842
2678
|
# @yield [data_validation_builder] Optional configuration block.
|
|
1843
2679
|
# @return [void]
|
|
1844
2680
|
# @api public
|
|
1845
2681
|
#: (?String? sqref, **untyped opts) ?{ (DataValidationBuilder) -> void } -> void
|
|
1846
|
-
def
|
|
2682
|
+
def data_validation(sqref = nil, **opts, &)
|
|
1847
2683
|
sheet if @current_sheet.nil?
|
|
1848
2684
|
normalized_list = DslHelpers.normalize_data_validation(sqref, **opts, &)
|
|
1849
2685
|
@current_data_validations.concat(normalized_list)
|
|
1850
2686
|
end
|
|
1851
2687
|
|
|
2688
|
+
# @deprecated Use {#data_validation} instead.
|
|
2689
|
+
#: (?String? sqref, **untyped opts) ?{ (DataValidationBuilder) -> void } -> void
|
|
2690
|
+
def validate_data(...)
|
|
2691
|
+
warn "[DEPRECATION] `validate_data` is deprecated; use `data_validation` instead.", uplevel: 1
|
|
2692
|
+
data_validation(...)
|
|
2693
|
+
end
|
|
2694
|
+
|
|
1852
2695
|
# Adds a conditional formatting rule.
|
|
1853
2696
|
# Supports block configuration via {ConditionalFormatBuilder} and coordinate targeting (:columns, :rows).
|
|
1854
2697
|
#
|
|
@@ -1902,24 +2745,32 @@ module Xlsxrb
|
|
|
1902
2745
|
# @param source_ref [String] Source data range.
|
|
1903
2746
|
# @param row_fields [Array<Integer>] 0-based field indices for rows.
|
|
1904
2747
|
# @param data_fields [Array<Hash>] Data fields.
|
|
1905
|
-
# @param
|
|
1906
|
-
# @param
|
|
2748
|
+
# @param column_fields [Array<Integer>] 0-based field indices for columns.
|
|
2749
|
+
# @param col_fields [Array<Integer>] Deprecated alias for column_fields.
|
|
2750
|
+
# @param ref [String] Top-left destination cell (default: "E1").
|
|
2751
|
+
# @param dest_ref [String] Deprecated alias for ref.
|
|
1907
2752
|
# @param name [String, nil] Pivot table name.
|
|
1908
2753
|
# @param field_names [Array<String>, nil] Override field names.
|
|
1909
2754
|
# @param items [Array, nil] Items configuration.
|
|
1910
2755
|
# @param opts [Hash] Additional options.
|
|
1911
2756
|
# @return [void]
|
|
1912
2757
|
# @api public
|
|
1913
|
-
#: (untyped source_ref, row_fields: untyped, data_fields: untyped, ?col_fields: untyped, ?dest_ref: untyped, ?name: untyped, ?field_names: untyped, ?items: untyped, **untyped opts) -> void
|
|
1914
|
-
def pivot_table(source_ref, row_fields:, data_fields:, col_fields:
|
|
2758
|
+
#: (untyped source_ref, row_fields: untyped, data_fields: untyped, ?column_fields: untyped, ?col_fields: untyped, ?ref: untyped, ?dest_ref: untyped, ?name: untyped, ?field_names: untyped, ?items: untyped, **untyped opts) -> void
|
|
2759
|
+
def pivot_table(source_ref, row_fields:, data_fields:, column_fields: nil, col_fields: nil, ref: nil, dest_ref: nil, name: nil, field_names: nil, items: nil, **opts)
|
|
1915
2760
|
sheet if @current_sheet.nil?
|
|
2761
|
+
warn "[DEPRECATION] `col_fields:` is deprecated; use `column_fields:` instead.", uplevel: 1 if col_fields && column_fields.nil?
|
|
2762
|
+
warn "[DEPRECATION] `dest_ref:` is deprecated; use `ref:` instead.", uplevel: 1 if dest_ref && ref.nil?
|
|
2763
|
+
c_fields = column_fields || col_fields || []
|
|
2764
|
+
target_ref = ref || dest_ref || "E1"
|
|
1916
2765
|
@current_pivot_tables ||= []
|
|
1917
|
-
|
|
2766
|
+
entry = {
|
|
1918
2767
|
source_ref: source_ref, row_fields: row_fields,
|
|
1919
|
-
data_fields: data_fields,
|
|
1920
|
-
|
|
2768
|
+
data_fields: data_fields, column_fields: c_fields,
|
|
2769
|
+
col_fields: c_fields, ref: target_ref,
|
|
2770
|
+
dest_ref: target_ref, name: name,
|
|
1921
2771
|
field_names: field_names, items: items
|
|
1922
|
-
}
|
|
2772
|
+
}.merge(opts)
|
|
2773
|
+
@current_pivot_tables << entry
|
|
1923
2774
|
end
|
|
1924
2775
|
|
|
1925
2776
|
# Adds a comment to a cell.
|
|
@@ -1932,7 +2783,9 @@ module Xlsxrb
|
|
|
1932
2783
|
#: (String | Integer cell, String text, ?author: ::String) -> void
|
|
1933
2784
|
def comment(cell, text, author: "Author")
|
|
1934
2785
|
sheet if @current_sheet.nil?
|
|
1935
|
-
|
|
2786
|
+
ref_str = cell.to_s
|
|
2787
|
+
@current_comments << { ref: ref_str, text: text, author: author }
|
|
2788
|
+
nil
|
|
1936
2789
|
end
|
|
1937
2790
|
|
|
1938
2791
|
# Adds a threaded comment to a cell.
|
|
@@ -1951,8 +2804,9 @@ module Xlsxrb
|
|
|
1951
2804
|
#: (String | Integer cell, String text, ?author: untyped, ?timestamp: untyped, ?id: String?, ?parent_id: String?, ?done: bool?, ?user_id: String?, ?provider_id: String?) -> void
|
|
1952
2805
|
def threaded_comment(cell, text, author: "Author", timestamp: nil, id: nil, parent_id: nil, done: false, user_id: nil, provider_id: nil)
|
|
1953
2806
|
sheet if @current_sheet.nil?
|
|
2807
|
+
ref_str = cell.to_s
|
|
1954
2808
|
@current_threaded_comments << {
|
|
1955
|
-
|
|
2809
|
+
ref: ref_str,
|
|
1956
2810
|
text: text,
|
|
1957
2811
|
author: author,
|
|
1958
2812
|
timestamp: timestamp,
|
|
@@ -1962,7 +2816,9 @@ module Xlsxrb
|
|
|
1962
2816
|
user_id: user_id,
|
|
1963
2817
|
provider_id: provider_id
|
|
1964
2818
|
}.compact
|
|
2819
|
+
nil
|
|
1965
2820
|
end
|
|
2821
|
+
# @deprecated Use {#threaded_comment} instead. Will be removed in 0.2.0.
|
|
1966
2822
|
alias add_threaded_comment threaded_comment
|
|
1967
2823
|
|
|
1968
2824
|
# Adds a sparkline group.
|
|
@@ -1996,10 +2852,12 @@ module Xlsxrb
|
|
|
1996
2852
|
# @param range [String, nil] Data range for the sparkline (e.g. "A1:E1").
|
|
1997
2853
|
# @param type [Symbol, String, nil] Sparkline type (:line, :column, :win_loss / :stacked).
|
|
1998
2854
|
# @param opts [Hash] Additional sparkline options.
|
|
2855
|
+
# @deprecated Use {#sparkline_group} instead. Will be removed in 0.2.0.
|
|
1999
2856
|
# @return [void]
|
|
2000
2857
|
# @api public
|
|
2001
2858
|
#: (?location: String?, ?range: String?, ?type: (String | Symbol)?, **untyped opts) -> void
|
|
2002
2859
|
def add_sparkline(location: nil, range: nil, type: nil, **opts)
|
|
2860
|
+
warn "[DEPRECATION] #add_sparkline is deprecated; use #sparkline_group instead.", uplevel: 1
|
|
2003
2861
|
loc = location || opts.delete(:location_ref)
|
|
2004
2862
|
rng = range || opts.delete(:data_ref) || opts.delete(:data)
|
|
2005
2863
|
raise ArgumentError, "Missing required location: parameter for sparkline" unless loc
|
|
@@ -2015,6 +2873,10 @@ module Xlsxrb
|
|
|
2015
2873
|
|
|
2016
2874
|
# Merges a range of cells into a single cell.
|
|
2017
2875
|
#
|
|
2876
|
+
# @example
|
|
2877
|
+
# sheet.merge("A1:C1")
|
|
2878
|
+
#
|
|
2879
|
+
# @deprecated Passing coordinate keyword arguments (row:, col_start:, col_end:, row_start:, row_end:) is deprecated and will be removed in 0.2.0. Use a range string (e.g. merge("A1:C1")) instead.
|
|
2018
2880
|
# @param range [String, Hash, nil] Cell range (e.g. "A1:B2") or hash of coordinates.
|
|
2019
2881
|
# @param row [Integer, nil] Single row index.
|
|
2020
2882
|
# @param col_start [Integer, String, nil] Starting column.
|
|
@@ -2035,47 +2897,156 @@ module Xlsxrb
|
|
|
2035
2897
|
@current_merge_cells << canonical unless @current_merge_cells.include?(canonical)
|
|
2036
2898
|
end
|
|
2037
2899
|
|
|
2038
|
-
# Freezes window panes at the given row and column.
|
|
2900
|
+
# Freezes window panes at the given row and column, or queries freeze pane settings.
|
|
2039
2901
|
#
|
|
2040
|
-
# @param row [Integer] Number of rows to freeze.
|
|
2041
|
-
# @param
|
|
2902
|
+
# @param row [Integer, nil] Number of rows to freeze.
|
|
2903
|
+
# @param column [Integer, String, nil] Number of columns to freeze.
|
|
2904
|
+
# @param col [Integer, String, nil] Deprecated alias for column.
|
|
2905
|
+
# @return [Elements::FreezePane, Hash<Symbol, untyped>, nil, void]
|
|
2906
|
+
# @api public
|
|
2907
|
+
#: (?row: Integer | nil, ?column: (Integer | String)?, ?col: (Integer | String)?) -> (untyped | void)
|
|
2908
|
+
def freeze_pane(row: nil, column: nil, col: nil)
|
|
2909
|
+
sheet if @current_sheet.nil?
|
|
2910
|
+
if row.nil? && column.nil? && col.nil?
|
|
2911
|
+
return nil unless @current_freeze_pane
|
|
2912
|
+
return Elements::FreezePane.new(**@current_freeze_pane) if defined?(Elements::FreezePane)
|
|
2913
|
+
|
|
2914
|
+
return @current_freeze_pane
|
|
2915
|
+
end
|
|
2916
|
+
|
|
2917
|
+
warn "[DEPRECATION] `col:` is deprecated; use `column:` instead.", uplevel: 1 if col && column.nil?
|
|
2918
|
+
col_val = Elements::Cell._column_index(column || col || 0)
|
|
2919
|
+
@current_freeze_pane = { row: row || 0, col: col_val, column: col_val }
|
|
2920
|
+
nil
|
|
2921
|
+
end
|
|
2922
|
+
|
|
2923
|
+
# Sets or clears freeze pane configuration.
|
|
2924
|
+
#
|
|
2925
|
+
# @param opts [Elements::FreezePane, Hash, nil] Freeze pane options.
|
|
2042
2926
|
# @return [void]
|
|
2043
2927
|
# @api public
|
|
2044
|
-
#: (
|
|
2045
|
-
def freeze_pane(
|
|
2046
|
-
col = Elements::Cell.column_index(col)
|
|
2928
|
+
#: (untyped opts) -> void
|
|
2929
|
+
def freeze_pane=(opts)
|
|
2047
2930
|
sheet if @current_sheet.nil?
|
|
2048
|
-
|
|
2931
|
+
if opts.nil?
|
|
2932
|
+
@current_freeze_pane = nil
|
|
2933
|
+
else
|
|
2934
|
+
h = opts.respond_to?(:to_h) ? opts.to_h : opts
|
|
2935
|
+
c = h[:column] || h[:col]
|
|
2936
|
+
c = Elements::Cell._column_index(c) if c
|
|
2937
|
+
@current_freeze_pane = { row: h[:row] || 0, col: c || 0, column: c || 0 }
|
|
2938
|
+
end
|
|
2939
|
+
nil
|
|
2049
2940
|
end
|
|
2050
2941
|
|
|
2051
|
-
# Splits window panes without freezing.
|
|
2942
|
+
# Splits window panes without freezing or queries split pane settings.
|
|
2052
2943
|
#
|
|
2053
|
-
# @param x_split [Integer] Horizontal split in points.
|
|
2054
|
-
# @param y_split [Integer] Vertical split in points.
|
|
2944
|
+
# @param x_split [Integer, nil] Horizontal split in points.
|
|
2945
|
+
# @param y_split [Integer, nil] Vertical split in points.
|
|
2055
2946
|
# @param top_left_cell [String, nil] Top-left cell reference in bottom-right pane.
|
|
2947
|
+
# @param active_pane [String, Symbol, nil] Active pane identifier.
|
|
2948
|
+
# @param state [String, Symbol, nil] Split state.
|
|
2949
|
+
# @return [Elements::SplitPane, Hash<Symbol, untyped>, nil, void]
|
|
2950
|
+
# @api public
|
|
2951
|
+
#: (?x_split: Integer | nil, ?y_split: Integer | nil, ?top_left_cell: String?, ?active_pane: (String | Symbol)?, ?state: (String | Symbol)?) -> (untyped | void)
|
|
2952
|
+
def split_pane(x_split: nil, y_split: nil, top_left_cell: nil, active_pane: nil, state: nil)
|
|
2953
|
+
sheet if @current_sheet.nil?
|
|
2954
|
+
if x_split.nil? && y_split.nil? && top_left_cell.nil? && active_pane.nil? && state.nil?
|
|
2955
|
+
return nil unless @current_split_pane
|
|
2956
|
+
return Elements::SplitPane.new(**@current_split_pane) if defined?(Elements::SplitPane)
|
|
2957
|
+
|
|
2958
|
+
return @current_split_pane
|
|
2959
|
+
end
|
|
2960
|
+
|
|
2961
|
+
entry = { x_split: x_split || 0, y_split: y_split || 0, top_left_cell: top_left_cell }
|
|
2962
|
+
entry[:active_pane] = active_pane.to_s if active_pane
|
|
2963
|
+
entry[:state] = state.to_s if state
|
|
2964
|
+
@current_split_pane = entry
|
|
2965
|
+
nil
|
|
2966
|
+
end
|
|
2967
|
+
|
|
2968
|
+
# Sets or clears split pane configuration.
|
|
2969
|
+
#
|
|
2970
|
+
# @param opts [Elements::SplitPane, Hash, nil] Split pane options.
|
|
2056
2971
|
# @return [void]
|
|
2057
2972
|
# @api public
|
|
2058
|
-
#: (
|
|
2059
|
-
def split_pane(
|
|
2973
|
+
#: (untyped opts) -> void
|
|
2974
|
+
def split_pane=(opts)
|
|
2060
2975
|
sheet if @current_sheet.nil?
|
|
2061
|
-
|
|
2976
|
+
if opts.nil?
|
|
2977
|
+
@current_split_pane = nil
|
|
2978
|
+
else
|
|
2979
|
+
h = opts.respond_to?(:to_h) ? opts.to_h : opts
|
|
2980
|
+
entry = { x_split: h[:x_split] || 0, y_split: h[:y_split] || 0, top_left_cell: h[:top_left_cell] }
|
|
2981
|
+
entry[:active_pane] = h[:active_pane].to_s if h[:active_pane]
|
|
2982
|
+
entry[:state] = h[:state].to_s if h[:state]
|
|
2983
|
+
@current_split_pane = entry
|
|
2984
|
+
end
|
|
2985
|
+
nil
|
|
2062
2986
|
end
|
|
2063
2987
|
|
|
2064
|
-
# Sets the active cell selection on the current sheet.
|
|
2988
|
+
# Sets or queries the active cell selection on the current sheet.
|
|
2065
2989
|
#
|
|
2066
|
-
# @param active_cell [String] Active cell reference (e.g. "A1").
|
|
2990
|
+
# @param active_cell [String, nil] Active cell reference (e.g. "A1") or range (e.g. "A1:D10").
|
|
2067
2991
|
# @param sqref [String, nil] Selection range.
|
|
2068
2992
|
# @param pane [String, Symbol, nil] Target pane.
|
|
2069
|
-
# @return [void]
|
|
2993
|
+
# @return [Elements::Selection, Array<Elements::Selection>, Hash<Symbol, untyped>, nil, void]
|
|
2070
2994
|
# @api public
|
|
2071
|
-
#: (String active_cell, ?sqref: String?, ?pane: (String | Symbol)?) -> void
|
|
2072
|
-
def
|
|
2995
|
+
#: (?String? active_cell, ?sqref: String?, ?pane: (String | Symbol)?) -> (untyped | void)
|
|
2996
|
+
def selection(active_cell = nil, sqref: nil, pane: nil)
|
|
2073
2997
|
sheet if @current_sheet.nil?
|
|
2074
|
-
|
|
2998
|
+
if active_cell.nil? && sqref.nil? && pane.nil?
|
|
2999
|
+
return nil if @current_selection.nil?
|
|
3000
|
+
|
|
3001
|
+
if defined?(Elements::Selection)
|
|
3002
|
+
return @current_selection.map { |s| Elements::Selection.new(**s) } if @current_selection.is_a?(Array)
|
|
3003
|
+
|
|
3004
|
+
return Elements::Selection.new(**@current_selection)
|
|
3005
|
+
end
|
|
3006
|
+
|
|
3007
|
+
return @current_selection
|
|
3008
|
+
end
|
|
3009
|
+
|
|
3010
|
+
if sqref.nil? && active_cell.is_a?(String) && active_cell.include?(":")
|
|
3011
|
+
sqref = active_cell
|
|
3012
|
+
active_cell = sqref.split(":").first
|
|
3013
|
+
else
|
|
3014
|
+
sqref ||= active_cell
|
|
3015
|
+
end
|
|
3016
|
+
@current_selection = { active_cell: active_cell, sqref: sqref }
|
|
2075
3017
|
@current_selection[:pane] = pane if pane
|
|
3018
|
+
nil
|
|
3019
|
+
end
|
|
3020
|
+
|
|
3021
|
+
# Sets or clears the selection configuration.
|
|
3022
|
+
#
|
|
3023
|
+
# @param opts [Elements::Selection, Array<Elements::Selection, Hash>, Hash, nil]
|
|
3024
|
+
# @return [void]
|
|
3025
|
+
# @api public
|
|
3026
|
+
#: (untyped opts) -> void
|
|
3027
|
+
def selection=(opts)
|
|
3028
|
+
sheet if @current_sheet.nil?
|
|
3029
|
+
@current_selection = if opts.nil?
|
|
3030
|
+
nil
|
|
3031
|
+
elsif opts.is_a?(Array)
|
|
3032
|
+
opts.map { |o| o.respond_to?(:to_h) ? o.to_h : o }
|
|
3033
|
+
else
|
|
3034
|
+
opts.respond_to?(:to_h) ? opts.to_h : opts
|
|
3035
|
+
end
|
|
3036
|
+
nil
|
|
2076
3037
|
end
|
|
2077
3038
|
|
|
2078
|
-
#
|
|
3039
|
+
# @deprecated Use {#selection} instead.
|
|
3040
|
+
#: (String active_cell, ?sqref: String?, ?pane: (String | Symbol)?) -> void
|
|
3041
|
+
def select_cell(...)
|
|
3042
|
+
warn "[DEPRECATION] `select_cell` is deprecated; use `selection` instead.", uplevel: 1
|
|
3043
|
+
selection(...)
|
|
3044
|
+
end
|
|
3045
|
+
|
|
3046
|
+
# Configures page margins for printing (<pageMargins>).
|
|
3047
|
+
#
|
|
3048
|
+
# When called with no arguments, returns the page margins value object or hash.
|
|
3049
|
+
# When called with arguments, configures page margins and returns nil.
|
|
2079
3050
|
#
|
|
2080
3051
|
# @param left [Float, nil] Left margin.
|
|
2081
3052
|
# @param right [Float, nil] Right margin.
|
|
@@ -2083,79 +3054,212 @@ module Xlsxrb
|
|
|
2083
3054
|
# @param bottom [Float, nil] Bottom margin.
|
|
2084
3055
|
# @param header [Float, nil] Header margin.
|
|
2085
3056
|
# @param footer [Float, nil] Footer margin.
|
|
2086
|
-
# @return [void]
|
|
3057
|
+
# @return [Elements::PageMargins, Hash<Symbol, untyped>, nil, void]
|
|
2087
3058
|
# @api public
|
|
2088
|
-
#: (?left: Float?, ?right: Float?, ?top: Float?, ?bottom: Float?, ?header: Float?, ?footer: Float?) -> void
|
|
3059
|
+
#: (?left: Float?, ?right: Float?, ?top: Float?, ?bottom: Float?, ?header: Float?, ?footer: Float?) -> (untyped | void)
|
|
2089
3060
|
def page_margins(left: nil, right: nil, top: nil, bottom: nil, header: nil, footer: nil)
|
|
2090
3061
|
sheet if @current_sheet.nil?
|
|
3062
|
+
if left.nil? && right.nil? && top.nil? && bottom.nil? && header.nil? && footer.nil?
|
|
3063
|
+
return nil unless @current_page_margins
|
|
3064
|
+
return Elements::PageMargins.new(**@current_page_margins) if defined?(Elements::PageMargins)
|
|
3065
|
+
|
|
3066
|
+
return @current_page_margins
|
|
3067
|
+
end
|
|
3068
|
+
|
|
2091
3069
|
@current_page_margins = DslHelpers.normalize_page_margins(
|
|
2092
3070
|
left: left, right: right, top: top, bottom: bottom, header: header, footer: footer
|
|
2093
3071
|
)
|
|
3072
|
+
nil
|
|
2094
3073
|
end
|
|
2095
3074
|
|
|
2096
|
-
# Sets page
|
|
3075
|
+
# Sets or clears page margins configuration.
|
|
2097
3076
|
#
|
|
2098
|
-
# @param opts [Hash
|
|
3077
|
+
# @param opts [Hash, Elements::PageMargins, nil]
|
|
2099
3078
|
# @return [void]
|
|
2100
3079
|
# @api public
|
|
2101
|
-
#: (
|
|
3080
|
+
#: (untyped opts) -> void
|
|
3081
|
+
def page_margins=(opts)
|
|
3082
|
+
sheet if @current_sheet.nil?
|
|
3083
|
+
if opts.nil?
|
|
3084
|
+
@current_page_margins = nil
|
|
3085
|
+
else
|
|
3086
|
+
h = opts.respond_to?(:to_h) ? opts.to_h : opts
|
|
3087
|
+
@current_page_margins = DslHelpers.normalize_page_margins(**h)
|
|
3088
|
+
end
|
|
3089
|
+
nil
|
|
3090
|
+
end
|
|
3091
|
+
|
|
3092
|
+
# Configures or queries page setup configuration (<pageSetup>).
|
|
3093
|
+
#
|
|
3094
|
+
# When called with no arguments, returns the page setup value object or hash.
|
|
3095
|
+
# When called with keyword arguments, updates page setup and returns nil.
|
|
3096
|
+
#
|
|
3097
|
+
# @param opts [Hash] Page setup options (e.g. orientation: :landscape).
|
|
3098
|
+
# @return [Elements::PageSetup, Hash<Symbol, untyped>, void]
|
|
3099
|
+
# @api public
|
|
3100
|
+
#: (**untyped opts) -> (untyped | void)
|
|
2102
3101
|
def page_setup(**opts)
|
|
2103
3102
|
sheet if @current_sheet.nil?
|
|
3103
|
+
if opts.empty?
|
|
3104
|
+
return defined?(Elements::PageSetup) ? Elements::PageSetup.new(**@current_page_setup) : @current_page_setup
|
|
3105
|
+
end
|
|
3106
|
+
|
|
2104
3107
|
@current_page_setup.merge!(opts)
|
|
2105
|
-
|
|
3108
|
+
@current_sheet_properties[:fit_to_page] = true if (opts.key?(:fit_to_width) || opts.key?(:fit_to_height)) && !@current_sheet_properties.key?(:fit_to_page)
|
|
3109
|
+
nil
|
|
3110
|
+
end
|
|
2106
3111
|
|
|
2107
|
-
|
|
3112
|
+
# Sets page setup configuration.
|
|
3113
|
+
#
|
|
3114
|
+
# @param opts [Hash, Elements::PageSetup]
|
|
3115
|
+
# @return [void]
|
|
3116
|
+
# @api public
|
|
3117
|
+
#: (untyped opts) -> void
|
|
3118
|
+
def page_setup=(opts)
|
|
3119
|
+
sheet if @current_sheet.nil?
|
|
3120
|
+
h = opts.respond_to?(:to_h) ? opts.to_h : (opts || {})
|
|
3121
|
+
@current_page_setup = h.transform_keys(&:to_sym)
|
|
3122
|
+
nil
|
|
2108
3123
|
end
|
|
2109
3124
|
|
|
2110
|
-
# Configures headers and footers for printing.
|
|
3125
|
+
# Configures or queries headers and footers for printing (<headerFooter>).
|
|
3126
|
+
#
|
|
3127
|
+
# When called with no arguments, returns the header/footer value object or hash.
|
|
3128
|
+
# When called with keyword arguments, updates headers and footers and returns nil.
|
|
2111
3129
|
#
|
|
2112
3130
|
# @param opts [Hash] Header/footer options.
|
|
2113
|
-
# @return [void]
|
|
3131
|
+
# @return [Elements::HeaderFooter, Hash<Symbol, untyped>, void]
|
|
2114
3132
|
# @api public
|
|
2115
|
-
#: (**untyped opts) -> void
|
|
3133
|
+
#: (**untyped opts) -> (untyped | void)
|
|
2116
3134
|
def header_footer(**opts)
|
|
2117
3135
|
sheet if @current_sheet.nil?
|
|
3136
|
+
if opts.empty?
|
|
3137
|
+
return defined?(Elements::HeaderFooter) ? Elements::HeaderFooter.new(**@current_header_footer) : @current_header_footer
|
|
3138
|
+
end
|
|
3139
|
+
|
|
2118
3140
|
@current_header_footer.merge!(opts)
|
|
3141
|
+
nil
|
|
2119
3142
|
end
|
|
2120
3143
|
|
|
2121
|
-
# Sets
|
|
3144
|
+
# Sets header and footer configuration.
|
|
2122
3145
|
#
|
|
2123
|
-
# @param
|
|
2124
|
-
# @param value [Object] Option value.
|
|
3146
|
+
# @param opts [Hash, Elements::HeaderFooter]
|
|
2125
3147
|
# @return [void]
|
|
2126
3148
|
# @api public
|
|
2127
|
-
#: (
|
|
2128
|
-
def
|
|
3149
|
+
#: (untyped opts) -> void
|
|
3150
|
+
def header_footer=(opts)
|
|
3151
|
+
sheet if @current_sheet.nil?
|
|
3152
|
+
h = opts.respond_to?(:to_h) ? opts.to_h : (opts || {})
|
|
3153
|
+
@current_header_footer = h.transform_keys(&:to_sym)
|
|
3154
|
+
nil
|
|
3155
|
+
end
|
|
3156
|
+
|
|
3157
|
+
# Configures or queries print options (<printOptions>).
|
|
3158
|
+
#
|
|
3159
|
+
# When called with no arguments, returns the {Elements::PrintOptions} value object.
|
|
3160
|
+
# When called with arguments or keyword options, configures print options and returns nil.
|
|
3161
|
+
#
|
|
3162
|
+
# @param name [Symbol, String, Hash, Elements::MetadataRecord, nil] Option name or hash/record of options.
|
|
3163
|
+
# @param value [Object, nil] Option value.
|
|
3164
|
+
# @param opts [Hash] Additional print options.
|
|
3165
|
+
# @return [Elements::PrintOptions, void]
|
|
3166
|
+
# @api public
|
|
3167
|
+
#: (?Symbol | String | Hash[Symbol, untyped] | Elements::MetadataRecord | nil name, ?untyped value, **untyped opts) -> (Elements::PrintOptions | void)
|
|
3168
|
+
def print_options(name = nil, value = nil, **opts)
|
|
2129
3169
|
sheet if @current_sheet.nil?
|
|
2130
|
-
|
|
3170
|
+
return Elements::PrintOptions.new(**@current_print_options) if name.nil? && value.nil? && opts.empty?
|
|
3171
|
+
|
|
3172
|
+
if name.is_a?(Hash) || (name.respond_to?(:to_h) && !name.is_a?(Symbol) && !name.is_a?(String))
|
|
3173
|
+
opts = name.to_h.merge(opts)
|
|
3174
|
+
name = nil
|
|
3175
|
+
end
|
|
3176
|
+
@current_print_options[name.to_sym] = value if name && !value.nil?
|
|
3177
|
+
opts.each { |k, v| @current_print_options[k.to_sym] = v }
|
|
3178
|
+
nil
|
|
2131
3179
|
end
|
|
2132
3180
|
|
|
2133
|
-
#
|
|
3181
|
+
# Replaces print options with the given hash or {Elements::PrintOptions} object.
|
|
3182
|
+
#
|
|
3183
|
+
# @param opts [Hash, Elements::PrintOptions]
|
|
3184
|
+
# @return [void]
|
|
3185
|
+
# @api public
|
|
3186
|
+
#: (Hash[Symbol, untyped] | Elements::PrintOptions opts) -> void
|
|
3187
|
+
def print_options=(opts)
|
|
3188
|
+
sheet if @current_sheet.nil?
|
|
3189
|
+
h = opts.respond_to?(:to_h) ? opts.to_h : (opts || {})
|
|
3190
|
+
@current_print_options = h.transform_keys(&:to_sym)
|
|
3191
|
+
nil
|
|
3192
|
+
end
|
|
3193
|
+
|
|
3194
|
+
# Configures or queries sheet-level protection with optional password hashing (<sheetProtection>).
|
|
3195
|
+
#
|
|
3196
|
+
# When called with no arguments, returns the sheet protection value object or hash.
|
|
3197
|
+
# When called with keyword arguments, sets sheet protection and returns nil.
|
|
2134
3198
|
#
|
|
2135
3199
|
# @param opts [Hash] Protection options.
|
|
3200
|
+
# @return [Elements::SheetProtection, Hash<Symbol, untyped>, nil, void]
|
|
3201
|
+
# @api public
|
|
3202
|
+
#: (**untyped opts) -> (untyped | void)
|
|
3203
|
+
def sheet_protection(**opts)
|
|
3204
|
+
sheet if @current_sheet.nil?
|
|
3205
|
+
if opts.empty?
|
|
3206
|
+
return nil unless @current_sheet_protection
|
|
3207
|
+
return Elements::SheetProtection.new(**@current_sheet_protection) if defined?(Elements::SheetProtection)
|
|
3208
|
+
|
|
3209
|
+
@current_sheet_protection
|
|
3210
|
+
else
|
|
3211
|
+
@current_sheet_protection = DslHelpers.normalize_protection_options(opts)
|
|
3212
|
+
nil
|
|
3213
|
+
end
|
|
3214
|
+
end
|
|
3215
|
+
|
|
3216
|
+
# Sets or clears sheet protection configuration.
|
|
3217
|
+
#
|
|
3218
|
+
# @param opts [Elements::SheetProtection, Hash, Boolean, nil]
|
|
2136
3219
|
# @return [void]
|
|
2137
3220
|
# @api public
|
|
2138
|
-
#: (
|
|
2139
|
-
def
|
|
3221
|
+
#: (untyped opts) -> void
|
|
3222
|
+
def sheet_protection=(opts)
|
|
2140
3223
|
sheet if @current_sheet.nil?
|
|
2141
|
-
|
|
3224
|
+
if opts.nil? || opts == false
|
|
3225
|
+
@current_sheet_protection = nil
|
|
3226
|
+
elsif opts == true
|
|
3227
|
+
@current_sheet_protection = DslHelpers.normalize_protection_options(sheet: true)
|
|
3228
|
+
else
|
|
3229
|
+
h = opts.respond_to?(:to_h) ? opts.to_h : opts
|
|
3230
|
+
@current_sheet_protection = DslHelpers.normalize_protection_options(h)
|
|
3231
|
+
end
|
|
3232
|
+
nil
|
|
3233
|
+
end
|
|
3234
|
+
|
|
3235
|
+
# @deprecated Use {#sheet_protection} instead.
|
|
3236
|
+
#: (**untyped opts) -> void
|
|
3237
|
+
def protect_sheet(...)
|
|
3238
|
+
warn "[DEPRECATION] `protect_sheet` is deprecated; use `sheet_protection` instead.", uplevel: 1
|
|
3239
|
+
sheet_protection(...)
|
|
2142
3240
|
end
|
|
2143
3241
|
|
|
2144
3242
|
# Inserts an embedded image into the active sheet.
|
|
2145
3243
|
#
|
|
2146
3244
|
# @param file_data [String] Binary image data.
|
|
2147
3245
|
# @param ext [String] File extension ("png", "jpeg", etc.).
|
|
2148
|
-
# @param
|
|
3246
|
+
# @param from_column [Integer, nil] Top-left starting column.
|
|
3247
|
+
# @param from_col [Integer, nil] Deprecated alias for from_column.
|
|
2149
3248
|
# @param from_row [Integer] Top-left starting row.
|
|
2150
|
-
# @param
|
|
3249
|
+
# @param to_column [Integer, nil] Bottom-right ending column.
|
|
3250
|
+
# @param to_col [Integer, nil] Deprecated alias for to_column.
|
|
2151
3251
|
# @param to_row [Integer] Bottom-right ending row.
|
|
2152
3252
|
# @param opts [Hash] Additional options.
|
|
2153
3253
|
# @return [void]
|
|
2154
3254
|
# @api public
|
|
2155
|
-
#: (String file_data, ?ext: ::String, ?from_col: ::Integer
|
|
2156
|
-
def image(file_data, ext: "png", from_col:
|
|
3255
|
+
#: (String file_data, ?ext: ::String, ?from_column: ::Integer?, ?from_col: ::Integer?, ?from_row: ::Integer, ?to_column: ::Integer?, ?to_col: ::Integer?, ?to_row: ::Integer, **untyped opts) -> void
|
|
3256
|
+
def image(file_data, ext: "png", from_column: nil, from_col: nil, from_row: 0, to_column: nil, to_col: nil, to_row: 10, **opts)
|
|
3257
|
+
warn "[DEPRECATION] `from_col:` is deprecated; use `from_column:` instead.", uplevel: 1 if from_col && from_column.nil?
|
|
3258
|
+
warn "[DEPRECATION] `to_col:` is deprecated; use `to_column:` instead.", uplevel: 1 if to_col && to_column.nil?
|
|
3259
|
+
fc = from_column || from_col || 0
|
|
3260
|
+
tc = to_column || to_col || 5
|
|
2157
3261
|
sheet if @current_sheet.nil?
|
|
2158
|
-
img = { file_data: file_data, ext: ext, from_col:
|
|
3262
|
+
img = { file_data: file_data, ext: ext, from_column: fc, from_col: fc, from_row: from_row, to_column: tc, to_col: tc, to_row: to_row }
|
|
2159
3263
|
img.merge!(opts)
|
|
2160
3264
|
@current_images << img
|
|
2161
3265
|
end
|
|
@@ -2168,6 +3272,7 @@ module Xlsxrb
|
|
|
2168
3272
|
# @example Set background image from file path
|
|
2169
3273
|
# sheet.background_image("path/to/background.png")
|
|
2170
3274
|
#
|
|
3275
|
+
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#background_image=} instead.
|
|
2171
3276
|
# @param file_data [String, Hash, Elements::Image, nil] Image binary data, file path, or image options hash.
|
|
2172
3277
|
# @param ext [String, nil] Image extension ("png", "jpeg", "jpg", "gif", etc.).
|
|
2173
3278
|
# @param opts [Hash] Additional image options.
|
|
@@ -2175,7 +3280,11 @@ module Xlsxrb
|
|
|
2175
3280
|
# @api public
|
|
2176
3281
|
#: (?untyped file_data, ?ext: ::String?, **untyped opts) -> Hash[Symbol, untyped]?
|
|
2177
3282
|
def background_image(file_data = nil, ext: nil, **opts)
|
|
2178
|
-
|
|
3283
|
+
if file_data.nil? && ext.nil? && opts.empty?
|
|
3284
|
+
return nil unless @current_background_image
|
|
3285
|
+
|
|
3286
|
+
return @current_background_image.is_a?(Elements::BackgroundImage) ? @current_background_image : Elements::BackgroundImage.new(**@current_background_image)
|
|
3287
|
+
end
|
|
2179
3288
|
|
|
2180
3289
|
sheet if @current_sheet.nil?
|
|
2181
3290
|
|
|
@@ -2211,37 +3320,55 @@ module Xlsxrb
|
|
|
2211
3320
|
content_type: mime
|
|
2212
3321
|
}.merge(opts).freeze
|
|
2213
3322
|
end
|
|
3323
|
+
# @deprecated Use {#background_image} instead. Will be removed in 0.2.0.
|
|
2214
3324
|
alias background_picture background_image
|
|
3325
|
+
# @deprecated Use {#background_image} instead. Will be removed in 0.2.0.
|
|
2215
3326
|
alias picture background_image
|
|
2216
3327
|
|
|
3328
|
+
#: (untyped val) -> untyped
|
|
2217
3329
|
def background_image=(val)
|
|
2218
|
-
|
|
3330
|
+
sheet if @current_sheet.nil?
|
|
3331
|
+
if val.nil?
|
|
3332
|
+
@current_background_image = nil
|
|
3333
|
+
else
|
|
3334
|
+
background_image(val)
|
|
3335
|
+
end
|
|
3336
|
+
val
|
|
2219
3337
|
end
|
|
3338
|
+
# @deprecated Use {#background_image=} instead. Will be removed in 0.2.0.
|
|
2220
3339
|
alias background_picture= background_image=
|
|
3340
|
+
# @deprecated Use {#background_image=} instead. Will be removed in 0.2.0.
|
|
2221
3341
|
alias picture= background_image=
|
|
2222
3342
|
|
|
2223
3343
|
# Inserts a drawing shape.
|
|
2224
3344
|
#
|
|
2225
3345
|
# @param preset [String] Preset shape name.
|
|
2226
3346
|
# @param text [String, nil] Label text.
|
|
2227
|
-
# @param
|
|
3347
|
+
# @param from_column [Integer, nil] Top-left column.
|
|
3348
|
+
# @param from_col [Integer, nil] Deprecated alias for from_column.
|
|
2228
3349
|
# @param from_row [Integer] Top-left row.
|
|
2229
|
-
# @param
|
|
3350
|
+
# @param to_column [Integer, nil] Bottom-right column.
|
|
3351
|
+
# @param to_col [Integer, nil] Deprecated alias for to_column.
|
|
2230
3352
|
# @param to_row [Integer] Bottom-right row.
|
|
2231
3353
|
# @param opts [Hash] Additional options.
|
|
2232
3354
|
# @return [void]
|
|
2233
3355
|
# @api public
|
|
2234
3356
|
#: (**untyped opts) -> void
|
|
2235
|
-
def shape(preset: "rect", text: nil, from_col:
|
|
3357
|
+
def shape(preset: "rect", text: nil, from_column: nil, from_col: nil, from_row: 0, to_column: nil, to_col: nil, to_row: 5, **opts)
|
|
3358
|
+
warn "[DEPRECATION] `from_col:` is deprecated; use `from_column:` instead.", uplevel: 1 if from_col && from_column.nil?
|
|
3359
|
+
warn "[DEPRECATION] `to_col:` is deprecated; use `to_column:` instead.", uplevel: 1 if to_col && to_column.nil?
|
|
3360
|
+
fc = from_column || from_col || 0
|
|
3361
|
+
tc = to_column || to_col || 5
|
|
2236
3362
|
sheet if @current_sheet.nil?
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
@current_shapes <<
|
|
3363
|
+
shape_data = { preset: preset, text: text, from_column: fc, from_col: fc, from_row: from_row, to_column: tc, to_col: tc, to_row: to_row }
|
|
3364
|
+
shape_data[:name] = opts.delete(:name) || "Shape #{@current_shapes.size + 1}"
|
|
3365
|
+
shape_data.merge!(opts)
|
|
3366
|
+
@current_shapes << shape_data
|
|
2241
3367
|
end
|
|
2242
3368
|
|
|
2243
3369
|
# Gets or sets the sheet visibility state (:visible, :hidden, or :very_hidden).
|
|
2244
3370
|
#
|
|
3371
|
+
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#state=} instead.
|
|
2245
3372
|
# @param new_state [Symbol, nil] The new state.
|
|
2246
3373
|
# @return [Symbol]
|
|
2247
3374
|
# @api public
|
|
@@ -2256,16 +3383,29 @@ module Xlsxrb
|
|
|
2256
3383
|
end
|
|
2257
3384
|
end
|
|
2258
3385
|
|
|
3386
|
+
# Sets the sheet visibility state (:visible, :hidden, or :very_hidden).
|
|
3387
|
+
#
|
|
3388
|
+
# @param new_state [Symbol, String] The new state.
|
|
3389
|
+
# @return [Symbol]
|
|
3390
|
+
# @api public
|
|
3391
|
+
#: (Symbol | String new_state) -> Symbol
|
|
3392
|
+
def state=(new_state)
|
|
3393
|
+
sheet if @current_sheet.nil?
|
|
3394
|
+
sheet_properties(:state, new_state)
|
|
3395
|
+
@current_sheet_state
|
|
3396
|
+
end
|
|
3397
|
+
|
|
2259
3398
|
# Gets or sets the tab color of the current worksheet.
|
|
2260
3399
|
#
|
|
3400
|
+
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#tab_color=} instead.
|
|
2261
3401
|
# @param spec [String, Hash, Symbol, nil] Tab color hex string or hash options.
|
|
2262
3402
|
# @param opts [Hash] Color keyword arguments (e.g. theme: 1, tint: 0.5).
|
|
2263
3403
|
# @return [String, Hash, nil]
|
|
2264
3404
|
# @api public
|
|
2265
3405
|
#: (?String | Symbol | Hash[Symbol, untyped] | nil spec, **untyped opts) -> (String | Hash[Symbol, untyped] | nil)
|
|
2266
|
-
def tab_color(spec =
|
|
3406
|
+
def tab_color(spec = OMITTED, **opts)
|
|
2267
3407
|
sheet if @current_sheet.nil?
|
|
2268
|
-
if spec.
|
|
3408
|
+
if spec.equal?(OMITTED) && opts.empty?
|
|
2269
3409
|
@current_sheet_properties[:tab_color]
|
|
2270
3410
|
else
|
|
2271
3411
|
color = if opts.empty?
|
|
@@ -2276,90 +3416,202 @@ module Xlsxrb
|
|
|
2276
3416
|
@current_sheet_properties[:tab_color] = color
|
|
2277
3417
|
end
|
|
2278
3418
|
end
|
|
2279
|
-
alias tab_color= tab_color
|
|
2280
3419
|
|
|
2281
|
-
# Sets
|
|
3420
|
+
# Sets the tab color of the current worksheet.
|
|
2282
3421
|
#
|
|
2283
|
-
# @param
|
|
3422
|
+
# @param spec [String, Hash, Symbol, nil] Tab color hex string or hash options.
|
|
3423
|
+
# @return [String, Hash, nil]
|
|
3424
|
+
# @api public
|
|
3425
|
+
#: (String | Symbol | Hash[Symbol, untyped] | nil spec) -> (String | Hash[Symbol, untyped] | nil)
|
|
3426
|
+
def tab_color=(spec)
|
|
3427
|
+
sheet if @current_sheet.nil?
|
|
3428
|
+
@current_sheet_properties[:tab_color] = spec
|
|
3429
|
+
end
|
|
3430
|
+
|
|
3431
|
+
# Sets a single sheet property.
|
|
3432
|
+
#
|
|
3433
|
+
# @param name [Symbol, String] Property name.
|
|
2284
3434
|
# @param value [Object] Property value.
|
|
2285
3435
|
# @return [void]
|
|
2286
3436
|
# @api public
|
|
2287
|
-
#: (Symbol name, untyped value) -> void
|
|
2288
|
-
def
|
|
3437
|
+
#: (Symbol | String name, untyped value) -> void
|
|
3438
|
+
def sheet_property(name, value)
|
|
3439
|
+
sheet_properties(name, value)
|
|
3440
|
+
end
|
|
3441
|
+
|
|
3442
|
+
# Configures or queries sheet properties (<sheetPr>).
|
|
3443
|
+
#
|
|
3444
|
+
# When called with no arguments, returns the {Elements::SheetProperties} value object.
|
|
3445
|
+
# When called with arguments or keyword options, configures properties and returns nil.
|
|
3446
|
+
#
|
|
3447
|
+
# @param name [Symbol, String, Hash, Elements::MetadataRecord, nil] Property name or hash/record of properties.
|
|
3448
|
+
# @param value [Object, nil] Property value when name is provided.
|
|
3449
|
+
# @param opts [Hash] Additional sheet properties.
|
|
3450
|
+
# @return [Elements::SheetProperties, void]
|
|
3451
|
+
# @api public
|
|
3452
|
+
#: (?Symbol | String | Hash[Symbol, untyped] | Elements::MetadataRecord | nil name, ?untyped value, **untyped opts) -> (Elements::SheetProperties | void)
|
|
3453
|
+
def sheet_properties(name = nil, value = nil, **opts)
|
|
2289
3454
|
sheet if @current_sheet.nil?
|
|
2290
|
-
|
|
2291
|
-
if sym == :state
|
|
2292
|
-
val = value.to_sym
|
|
2293
|
-
raise ArgumentError, "Invalid sheet state ':#{val}'. Allowed states are :visible, :hidden, :very_hidden" unless VALID_SHEET_STATES.include?(val)
|
|
3455
|
+
return Elements::SheetProperties.new(**@current_sheet_properties) if name.nil? && value.nil? && opts.empty?
|
|
2294
3456
|
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
3457
|
+
if name.is_a?(Hash) || (name.respond_to?(:to_h) && !name.is_a?(Symbol) && !name.is_a?(String))
|
|
3458
|
+
opts = name.to_h.merge(opts)
|
|
3459
|
+
name = nil
|
|
3460
|
+
end
|
|
3461
|
+
if name && !value.nil?
|
|
3462
|
+
sym = name.to_sym
|
|
3463
|
+
if sym == :state
|
|
3464
|
+
val = value.to_sym
|
|
3465
|
+
raise ArgumentError, "Invalid sheet state ':#{val}'. Allowed states are :visible, :hidden, :very_hidden" unless VALID_SHEET_STATES.include?(val)
|
|
3466
|
+
|
|
3467
|
+
@current_sheet_state = val
|
|
3468
|
+
return nil
|
|
3469
|
+
elsif sym == :hidden
|
|
3470
|
+
@current_sheet_state = value ? :hidden : :visible
|
|
3471
|
+
return nil
|
|
3472
|
+
end
|
|
3473
|
+
@current_sheet_properties[name.to_sym] = value
|
|
2300
3474
|
end
|
|
3475
|
+
opts.each { |k, v| sheet_properties(k, v) }
|
|
3476
|
+
nil
|
|
3477
|
+
end
|
|
2301
3478
|
|
|
2302
|
-
|
|
3479
|
+
# Replaces worksheet properties with the given hash or {Elements::SheetProperties} object.
|
|
3480
|
+
#
|
|
3481
|
+
# @param opts [Hash, Elements::SheetProperties]
|
|
3482
|
+
# @return [void]
|
|
3483
|
+
# @api public
|
|
3484
|
+
#: (Hash[Symbol, untyped] | Elements::SheetProperties opts) -> void
|
|
3485
|
+
def sheet_properties=(opts)
|
|
3486
|
+
sheet if @current_sheet.nil?
|
|
3487
|
+
h = opts.respond_to?(:to_h) ? opts.to_h : (opts || {})
|
|
3488
|
+
@current_sheet_properties = {}
|
|
3489
|
+
h.each { |k, v| sheet_properties(k, v) }
|
|
3490
|
+
nil
|
|
3491
|
+
end
|
|
3492
|
+
|
|
3493
|
+
# Configures or queries sheet view display properties (<sheetView>).
|
|
3494
|
+
#
|
|
3495
|
+
# When called with no arguments, returns the {Elements::SheetView} value object.
|
|
3496
|
+
# When called with arguments or keyword options, configures view properties and returns nil.
|
|
3497
|
+
#
|
|
3498
|
+
# @param name [Symbol, String, Hash, Elements::MetadataRecord, nil] View property name or hash/record of properties.
|
|
3499
|
+
# @param value [Object, nil] View property value when name is provided.
|
|
3500
|
+
# @param opts [Hash] Additional view properties.
|
|
3501
|
+
# @return [Elements::SheetView, void]
|
|
3502
|
+
# @api public
|
|
3503
|
+
#: (?Symbol | String | Hash[Symbol, untyped] | Elements::MetadataRecord | nil name, ?untyped value, **untyped opts) -> (Elements::SheetView | void)
|
|
3504
|
+
def sheet_view(name = nil, value = nil, **opts)
|
|
3505
|
+
sheet if @current_sheet.nil?
|
|
3506
|
+
return Elements::SheetView.new(**@current_sheet_view) if name.nil? && value.nil? && opts.empty?
|
|
3507
|
+
|
|
3508
|
+
if name.is_a?(Hash) || (name.respond_to?(:to_h) && !name.is_a?(Symbol) && !name.is_a?(String))
|
|
3509
|
+
opts = name.to_h.merge(opts)
|
|
3510
|
+
name = nil
|
|
3511
|
+
end
|
|
3512
|
+
@current_sheet_view[name.to_sym] = value if name && !value.nil?
|
|
3513
|
+
opts.each { |k, v| @current_sheet_view[k.to_sym] = v }
|
|
3514
|
+
nil
|
|
2303
3515
|
end
|
|
2304
3516
|
|
|
2305
|
-
#
|
|
3517
|
+
# Replaces sheet view properties with the given hash or {Elements::SheetView} object.
|
|
2306
3518
|
#
|
|
2307
|
-
# @param
|
|
2308
|
-
# @param value [Object] View property value.
|
|
3519
|
+
# @param opts [Hash, Elements::SheetView]
|
|
2309
3520
|
# @return [void]
|
|
2310
3521
|
# @api public
|
|
2311
|
-
#: (Symbol
|
|
2312
|
-
def sheet_view(
|
|
3522
|
+
#: (Hash[Symbol, untyped] | Elements::SheetView opts) -> void
|
|
3523
|
+
def sheet_view=(opts)
|
|
2313
3524
|
sheet if @current_sheet.nil?
|
|
2314
|
-
|
|
3525
|
+
h = opts.respond_to?(:to_h) ? opts.to_h : (opts || {})
|
|
3526
|
+
@current_sheet_view = h.transform_keys(&:to_sym)
|
|
3527
|
+
nil
|
|
2315
3528
|
end
|
|
2316
3529
|
|
|
2317
|
-
# Configures sheet format properties (
|
|
3530
|
+
# Configures or queries sheet format properties (<sheetFormatPr>).
|
|
2318
3531
|
#
|
|
2319
|
-
#
|
|
3532
|
+
# When called with no arguments, returns the {Elements::SheetFormat} value object.
|
|
3533
|
+
# When called with arguments or keyword options, configures format properties and returns nil.
|
|
3534
|
+
#
|
|
3535
|
+
# @param name [Symbol, String, Hash, Elements::MetadataRecord, nil] Property name or hash/record of properties.
|
|
2320
3536
|
# @param value [Object, nil] Property value when name is provided.
|
|
2321
3537
|
# @param opts [Hash] Keyword arguments for sheet format properties.
|
|
2322
|
-
# @return [
|
|
3538
|
+
# @return [Elements::SheetFormat, void]
|
|
2323
3539
|
# @api public
|
|
2324
|
-
#: (?Symbol | String | Hash[Symbol, untyped] | nil name, ?untyped value, **untyped opts) ->
|
|
3540
|
+
#: (?Symbol | String | Hash[Symbol, untyped] | Elements::MetadataRecord | nil name, ?untyped value, **untyped opts) -> (Elements::SheetFormat | void)
|
|
2325
3541
|
def sheet_format(name = nil, value = nil, **opts)
|
|
2326
3542
|
sheet if @current_sheet.nil?
|
|
2327
|
-
if name.
|
|
2328
|
-
|
|
3543
|
+
return Elements::SheetFormat.new(**@current_sheet_format) if name.nil? && value.nil? && opts.empty?
|
|
3544
|
+
|
|
3545
|
+
if name.is_a?(Hash) || (name.respond_to?(:to_h) && !name.is_a?(Symbol) && !name.is_a?(String))
|
|
3546
|
+
@current_sheet_format.merge!(name.to_h)
|
|
2329
3547
|
elsif name && value
|
|
2330
3548
|
@current_sheet_format[name.to_sym] = value
|
|
2331
3549
|
end
|
|
3550
|
+
if opts.key?(:default_col_width) && !opts.key?(:default_column_width)
|
|
3551
|
+
warn "[DEPRECATION] `default_col_width:` is deprecated; use `default_column_width:` instead.", uplevel: 1
|
|
3552
|
+
opts[:default_column_width] = opts[:default_col_width]
|
|
3553
|
+
end
|
|
3554
|
+
if opts.key?(:base_col_width) && !opts.key?(:base_column_width)
|
|
3555
|
+
warn "[DEPRECATION] `base_col_width:` is deprecated; use `base_column_width:` instead.", uplevel: 1
|
|
3556
|
+
opts[:base_column_width] = opts[:base_col_width]
|
|
3557
|
+
end
|
|
3558
|
+
if opts.key?(:outline_level_col) && !opts.key?(:outline_level_column)
|
|
3559
|
+
warn "[DEPRECATION] `outline_level_col:` is deprecated; use `outline_level_column:` instead.", uplevel: 1
|
|
3560
|
+
opts[:outline_level_column] = opts[:outline_level_col]
|
|
3561
|
+
end
|
|
2332
3562
|
@current_sheet_format.merge!(opts) unless opts.empty?
|
|
2333
|
-
|
|
3563
|
+
nil
|
|
2334
3564
|
end
|
|
2335
3565
|
|
|
2336
|
-
#
|
|
3566
|
+
# Replaces sheet format properties with the given hash or {Elements::SheetFormat} object.
|
|
2337
3567
|
#
|
|
2338
|
-
# @param
|
|
3568
|
+
# @param opts [Hash, Elements::SheetFormat]
|
|
2339
3569
|
# @return [void]
|
|
2340
3570
|
# @api public
|
|
3571
|
+
#: (Hash[Symbol, untyped] | Elements::SheetFormat opts) -> void
|
|
3572
|
+
def sheet_format=(opts)
|
|
3573
|
+
sheet if @current_sheet.nil?
|
|
3574
|
+
h = opts.respond_to?(:to_h) ? opts.to_h : (opts || {})
|
|
3575
|
+
@current_sheet_format = {}
|
|
3576
|
+
sheet_format(h)
|
|
3577
|
+
nil
|
|
3578
|
+
end
|
|
3579
|
+
|
|
3580
|
+
# Inserts a horizontal page break after the given 0-based row.
|
|
3581
|
+
#
|
|
3582
|
+
# @param row_index [Integer] 0-based row index.
|
|
3583
|
+
# @return [void]
|
|
3584
|
+
# @api public
|
|
3585
|
+
#: (Integer row_index) -> void
|
|
3586
|
+
def row_break(row_index)
|
|
3587
|
+
sheet if @current_sheet.nil?
|
|
3588
|
+
@current_row_breaks << { id: row_index, max: 16_383, man: 1 }
|
|
3589
|
+
end
|
|
3590
|
+
|
|
3591
|
+
# @deprecated Use {#row_break} instead.
|
|
2341
3592
|
#: (Integer row_num) -> void
|
|
2342
3593
|
def page_break_row(row_num)
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
sheet if @current_sheet.nil?
|
|
2346
|
-
@current_row_breaks << row_num
|
|
2347
|
-
# simplecov:enable
|
|
3594
|
+
warn "[DEPRECATION] `page_break_row` is deprecated; use `row_break` instead.", uplevel: 1
|
|
3595
|
+
row_break(row_num)
|
|
2348
3596
|
end
|
|
2349
3597
|
|
|
2350
|
-
# Inserts a vertical page break
|
|
3598
|
+
# Inserts a vertical page break after the given column.
|
|
2351
3599
|
#
|
|
2352
|
-
# @param
|
|
3600
|
+
# @param col [Integer, String, Symbol] 0-based column index or letter ("B", :B).
|
|
2353
3601
|
# @return [void]
|
|
2354
3602
|
# @api public
|
|
2355
|
-
#: (Integer
|
|
2356
|
-
def
|
|
2357
|
-
|
|
2358
|
-
# Edge case / untested delegation block
|
|
2359
|
-
col_index = Elements::Cell.column_index(col_index)
|
|
3603
|
+
#: (Integer | String | Symbol col) -> void
|
|
3604
|
+
def column_break(col)
|
|
3605
|
+
col_index = Elements::Cell._column_index(col)
|
|
2360
3606
|
sheet if @current_sheet.nil?
|
|
2361
|
-
@current_col_breaks << col_index
|
|
2362
|
-
|
|
3607
|
+
@current_col_breaks << { id: col_index, max: 1_048_575, man: 1 }
|
|
3608
|
+
end
|
|
3609
|
+
|
|
3610
|
+
# @deprecated Use {#column_break} instead.
|
|
3611
|
+
#: (Integer | String | Symbol col_index) -> void
|
|
3612
|
+
def page_break_col(col_index)
|
|
3613
|
+
warn "[DEPRECATION] `page_break_col` is deprecated; use `column_break` instead.", uplevel: 1
|
|
3614
|
+
column_break(col_index)
|
|
2363
3615
|
end
|
|
2364
3616
|
|
|
2365
3617
|
# Adds a protected range to the current sheet.
|
|
@@ -2378,6 +3630,7 @@ module Xlsxrb
|
|
|
2378
3630
|
entry.merge!(opts) unless opts.empty?
|
|
2379
3631
|
@current_protected_ranges << DslHelpers.normalize_protection_options(entry)
|
|
2380
3632
|
end
|
|
3633
|
+
# @deprecated Use {#protected_range} instead. Will be removed in 0.2.0.
|
|
2381
3634
|
alias add_protected_range protected_range
|
|
2382
3635
|
|
|
2383
3636
|
# Adds a cell watch to the current sheet.
|
|
@@ -2390,6 +3643,7 @@ module Xlsxrb
|
|
|
2390
3643
|
sheet if @current_sheet.nil?
|
|
2391
3644
|
@current_cell_watches << ref.to_s
|
|
2392
3645
|
end
|
|
3646
|
+
# @deprecated Use {#cell_watch} instead. Will be removed in 0.2.0.
|
|
2393
3647
|
alias add_cell_watch cell_watch
|
|
2394
3648
|
|
|
2395
3649
|
# Adds an ignored error entry to the current sheet.
|
|
@@ -2399,11 +3653,24 @@ module Xlsxrb
|
|
|
2399
3653
|
# @return [void]
|
|
2400
3654
|
# @api public
|
|
2401
3655
|
#: (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
|
|
2402
|
-
def
|
|
3656
|
+
def ignored_error(sqref, **opts)
|
|
2403
3657
|
sheet if @current_sheet.nil?
|
|
2404
3658
|
@current_ignored_errors << { sqref: sqref.to_s }.merge(opts)
|
|
2405
3659
|
end
|
|
2406
|
-
|
|
3660
|
+
|
|
3661
|
+
# @deprecated Use {#ignored_error} instead. Will be removed in 0.2.0.
|
|
3662
|
+
#: (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
|
|
3663
|
+
def ignore_error(sqref, **opts)
|
|
3664
|
+
warn "[DEPRECATION] #ignore_error is deprecated; use #ignored_error instead.", uplevel: 1
|
|
3665
|
+
ignored_error(sqref, **opts)
|
|
3666
|
+
end
|
|
3667
|
+
|
|
3668
|
+
# @deprecated Use {#ignored_error} instead. Will be removed in 0.2.0.
|
|
3669
|
+
#: (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
|
|
3670
|
+
def add_ignored_error(sqref, **opts)
|
|
3671
|
+
warn "[DEPRECATION] #add_ignored_error is deprecated; use #ignored_error instead.", uplevel: 1
|
|
3672
|
+
ignored_error(sqref, **opts)
|
|
3673
|
+
end
|
|
2407
3674
|
|
|
2408
3675
|
# Returns the ignored error entries configured for the current sheet.
|
|
2409
3676
|
#
|
|
@@ -2411,11 +3678,12 @@ module Xlsxrb
|
|
|
2411
3678
|
# @api public
|
|
2412
3679
|
#: () -> Array[Hash[Symbol, untyped]]
|
|
2413
3680
|
def ignored_errors
|
|
2414
|
-
@current_ignored_errors.
|
|
3681
|
+
@current_ignored_errors.map { |ie| ie.is_a?(Elements::IgnoredError) ? ie : Elements::IgnoredError.new(**ie) }.freeze
|
|
2415
3682
|
end
|
|
2416
3683
|
|
|
2417
3684
|
# Gets or sets phonetic (furigana) guide properties for the current sheet.
|
|
2418
3685
|
#
|
|
3686
|
+
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#phonetic_properties=} instead.
|
|
2419
3687
|
# @overload phonetic_properties()
|
|
2420
3688
|
# Returns the current phonetic properties.
|
|
2421
3689
|
# @return [Hash, nil]
|
|
@@ -2427,11 +3695,15 @@ module Xlsxrb
|
|
|
2427
3695
|
# @param alignment [Symbol, String, nil]
|
|
2428
3696
|
# @return [Hash, nil]
|
|
2429
3697
|
# @api public
|
|
2430
|
-
#: (?
|
|
2431
|
-
def phonetic_properties(spec =
|
|
3698
|
+
#: (?untyped spec, ?font_id: Integer?, ?type: (Symbol | String)?, ?alignment: (Symbol | String)?, **untyped opts) -> (Elements::PhoneticProperties | Hash[Symbol, untyped] | nil)
|
|
3699
|
+
def phonetic_properties(spec = OMITTED, font_id: nil, type: nil, alignment: nil, **opts)
|
|
2432
3700
|
sheet if @current_sheet.nil?
|
|
2433
|
-
if spec.
|
|
2434
|
-
@current_phonetic_properties
|
|
3701
|
+
if spec.equal?(OMITTED) && font_id.nil? && type.nil? && alignment.nil? && opts.empty?
|
|
3702
|
+
return nil unless @current_phonetic_properties
|
|
3703
|
+
|
|
3704
|
+
@current_phonetic_properties.is_a?(Elements::PhoneticProperties) ? @current_phonetic_properties : Elements::PhoneticProperties.new(**@current_phonetic_properties)
|
|
3705
|
+
elsif !spec.equal?(OMITTED) && spec.nil? && font_id.nil? && type.nil? && alignment.nil? && opts.empty?
|
|
3706
|
+
@current_phonetic_properties = nil
|
|
2435
3707
|
else
|
|
2436
3708
|
props = if spec.is_a?(Hash)
|
|
2437
3709
|
spec.merge(opts)
|
|
@@ -2444,67 +3716,138 @@ module Xlsxrb
|
|
|
2444
3716
|
@current_phonetic_properties = WorksheetBuilder.normalize_phonetic_properties(props)
|
|
2445
3717
|
end
|
|
2446
3718
|
end
|
|
2447
|
-
|
|
3719
|
+
# @deprecated Use {#phonetic_properties} instead. Will be removed in 0.2.0.
|
|
2448
3720
|
alias phonetic_pr phonetic_properties
|
|
2449
|
-
|
|
3721
|
+
|
|
3722
|
+
# Sets phonetic (furigana) guide properties for the current sheet.
|
|
3723
|
+
#
|
|
3724
|
+
# @param spec [Hash, Integer, nil]
|
|
3725
|
+
# @return [Hash[Symbol, untyped], Integer, nil]
|
|
3726
|
+
# @api public
|
|
3727
|
+
#: (Hash[Symbol, untyped] | Integer | nil spec) -> (Hash[Symbol, untyped] | Integer | nil)
|
|
3728
|
+
def phonetic_properties=(spec)
|
|
3729
|
+
sheet if @current_sheet.nil?
|
|
3730
|
+
if spec.nil?
|
|
3731
|
+
@current_phonetic_properties = nil
|
|
3732
|
+
else
|
|
3733
|
+
props = if spec.is_a?(Hash)
|
|
3734
|
+
spec.dup
|
|
3735
|
+
elsif spec.is_a?(Integer)
|
|
3736
|
+
{ font_id: spec }
|
|
3737
|
+
else
|
|
3738
|
+
{}
|
|
3739
|
+
end
|
|
3740
|
+
@current_phonetic_properties = WorksheetBuilder.normalize_phonetic_properties(props)
|
|
3741
|
+
end
|
|
3742
|
+
spec
|
|
3743
|
+
end
|
|
3744
|
+
# @deprecated Use {#phonetic_properties=} instead. Will be removed in 0.2.0.
|
|
3745
|
+
alias phonetic_pr= phonetic_properties=
|
|
2450
3746
|
|
|
2451
3747
|
# Sets or gets the internal code name of the current worksheet (or workbook if no sheet is open).
|
|
2452
3748
|
#
|
|
3749
|
+
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#code_name=} instead.
|
|
2453
3750
|
# @param val [String, Symbol, nil] The code name.
|
|
2454
3751
|
# @return [String, nil]
|
|
2455
3752
|
# @api public
|
|
2456
3753
|
#: (?String | Symbol | nil val) -> String?
|
|
2457
|
-
def code_name(val =
|
|
3754
|
+
def code_name(val = OMITTED)
|
|
2458
3755
|
if @current_sheet.nil?
|
|
2459
|
-
if val.
|
|
3756
|
+
if val.equal?(OMITTED)
|
|
2460
3757
|
@workbook_properties[:code_name]
|
|
2461
3758
|
else
|
|
2462
|
-
@workbook_properties[:code_name] = val
|
|
3759
|
+
@workbook_properties[:code_name] = val&.to_s
|
|
2463
3760
|
end
|
|
2464
|
-
elsif val.
|
|
3761
|
+
elsif val.equal?(OMITTED)
|
|
2465
3762
|
@current_sheet_properties[:code_name]
|
|
2466
3763
|
else
|
|
2467
|
-
@current_sheet_properties[:code_name] = val
|
|
3764
|
+
@current_sheet_properties[:code_name] = val&.to_s
|
|
3765
|
+
end
|
|
3766
|
+
end
|
|
3767
|
+
|
|
3768
|
+
# Sets the internal code name of the current worksheet (or workbook if no sheet is open).
|
|
3769
|
+
#
|
|
3770
|
+
# @param val [String, Symbol, nil] The code name.
|
|
3771
|
+
# @return [String, nil]
|
|
3772
|
+
# @api public
|
|
3773
|
+
#: (String | Symbol | nil val) -> String?
|
|
3774
|
+
def code_name=(val)
|
|
3775
|
+
if @current_sheet.nil?
|
|
3776
|
+
@workbook_properties[:code_name] = val&.to_s
|
|
3777
|
+
else
|
|
3778
|
+
@current_sheet_properties[:code_name] = val&.to_s
|
|
2468
3779
|
end
|
|
2469
3780
|
end
|
|
2470
|
-
alias code_name= code_name
|
|
2471
3781
|
|
|
2472
3782
|
# Configures whether page setup fits content to page width/height for the current sheet.
|
|
2473
3783
|
# When enabled, optionally sets fit_to_width and/or fit_to_height on page_setup.
|
|
2474
3784
|
#
|
|
3785
|
+
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#fit_to_page=} or {#page_setup} with :fit_to_width/:fit_to_height instead.
|
|
2475
3786
|
# @param enabled [Boolean, nil] Whether to fit to page.
|
|
2476
3787
|
# @param width [Integer, nil] Pages wide to fit to.
|
|
2477
3788
|
# @param height [Integer, nil] Pages tall to fit to.
|
|
2478
3789
|
# @return [Boolean, void]
|
|
2479
3790
|
# @api public
|
|
2480
3791
|
#: (?bool? enabled, ?width: Integer?, ?height: Integer?) -> (bool | void)
|
|
2481
|
-
def fit_to_page(enabled =
|
|
3792
|
+
def fit_to_page(enabled = OMITTED, width: nil, height: nil)
|
|
2482
3793
|
sheet if @current_sheet.nil?
|
|
2483
|
-
if enabled.
|
|
3794
|
+
if enabled.equal?(OMITTED) && width.nil? && height.nil?
|
|
2484
3795
|
return @current_sheet_properties[:fit_to_page] ? true : false
|
|
2485
3796
|
end
|
|
2486
3797
|
|
|
2487
|
-
@current_sheet_properties[:fit_to_page] =
|
|
3798
|
+
@current_sheet_properties[:fit_to_page] = if enabled.equal?(OMITTED)
|
|
3799
|
+
true
|
|
3800
|
+
else
|
|
3801
|
+
enabled ? true : false
|
|
3802
|
+
end
|
|
2488
3803
|
page_setup(fit_to_width: width) if width
|
|
2489
3804
|
page_setup(fit_to_height: height) if height
|
|
2490
3805
|
end
|
|
2491
|
-
|
|
2492
|
-
|
|
3806
|
+
|
|
3807
|
+
# @deprecated Use {#fit_to_page} instead. Will be removed in 0.2.0.
|
|
3808
|
+
# @return [Boolean]
|
|
3809
|
+
# @api public
|
|
3810
|
+
#: () -> bool
|
|
3811
|
+
def fit_to_page?
|
|
3812
|
+
warn "[Xlsxrb DEPRECATION] fit_to_page? is deprecated; use fit_to_page instead.", uplevel: 1
|
|
3813
|
+
fit_to_page
|
|
3814
|
+
end
|
|
3815
|
+
|
|
3816
|
+
# Sets whether page setup fits content to page width/height for the current sheet.
|
|
3817
|
+
#
|
|
3818
|
+
# @param enabled [Boolean, nil] Whether to fit to page.
|
|
3819
|
+
# @return [Boolean]
|
|
3820
|
+
# @api public
|
|
3821
|
+
#: (bool? enabled) -> bool?
|
|
3822
|
+
def fit_to_page=(enabled)
|
|
3823
|
+
sheet if @current_sheet.nil?
|
|
3824
|
+
@current_sheet_properties[:fit_to_page] = enabled ? true : false
|
|
3825
|
+
end
|
|
2493
3826
|
|
|
2494
3827
|
# Configures worksheet calculation properties (<sheetCalcPr>) for the current sheet.
|
|
2495
3828
|
#
|
|
2496
3829
|
# @example Instruct Excel to recalculate formulas when loading sheet
|
|
2497
|
-
# w.
|
|
3830
|
+
# w.sheet_calc_properties = { full_calc_on_load: true }
|
|
2498
3831
|
#
|
|
3832
|
+
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#sheet_calc_properties=} instead.
|
|
2499
3833
|
# @param spec [Hash, nil] Calculation properties hash.
|
|
2500
3834
|
# @param full_calc_on_load [Boolean, nil] Whether to recalculate when loading.
|
|
2501
3835
|
# @return [Hash, nil]
|
|
2502
3836
|
# @api public
|
|
2503
|
-
#: (?
|
|
2504
|
-
def
|
|
3837
|
+
#: (?untyped spec, ?full_calc_on_load: bool?, **untyped opts) -> (Elements::SheetCalcProperties | Hash[Symbol, untyped] | nil)
|
|
3838
|
+
def sheet_calc_properties(spec = OMITTED, full_calc_on_load: nil, **opts)
|
|
2505
3839
|
sheet if @current_sheet.nil?
|
|
2506
|
-
if spec.
|
|
2507
|
-
|
|
3840
|
+
if spec.equal?(OMITTED) && full_calc_on_load.nil? && opts.empty?
|
|
3841
|
+
calc = @current_sheet_calc_pr || (@current_sheet_properties[:full_calc_on_load] ? { full_calc_on_load: true } : nil)
|
|
3842
|
+
return nil unless calc
|
|
3843
|
+
|
|
3844
|
+
return calc.is_a?(Elements::SheetCalcProperties) ? calc : Elements::SheetCalcProperties.new(**calc)
|
|
3845
|
+
end
|
|
3846
|
+
|
|
3847
|
+
warn "[DEPRECATION] Calling #sheet_calc_properties with arguments is deprecated and will be removed in 0.2.0. Use #sheet_calc_properties= instead.", uplevel: 1
|
|
3848
|
+
if !spec.equal?(OMITTED) && spec.nil? && full_calc_on_load.nil? && opts.empty?
|
|
3849
|
+
@current_sheet_properties.delete(:full_calc_on_load)
|
|
3850
|
+
return @current_sheet_calc_pr = nil
|
|
2508
3851
|
end
|
|
2509
3852
|
|
|
2510
3853
|
pr = spec.is_a?(Hash) ? spec.dup : {}
|
|
@@ -2513,9 +3856,53 @@ module Xlsxrb
|
|
|
2513
3856
|
@current_sheet_properties[:full_calc_on_load] = pr[:full_calc_on_load] unless pr[:full_calc_on_load].nil?
|
|
2514
3857
|
@current_sheet_calc_pr = pr
|
|
2515
3858
|
end
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
3859
|
+
|
|
3860
|
+
# Sets worksheet calculation properties (<sheetCalcPr>) for the current sheet.
|
|
3861
|
+
#
|
|
3862
|
+
# @param spec [Hash, nil] Calculation properties hash.
|
|
3863
|
+
# @return [Hash, nil]
|
|
3864
|
+
# @api public
|
|
3865
|
+
#: (Hash[Symbol, untyped]? spec) -> Hash[Symbol, untyped]?
|
|
3866
|
+
def sheet_calc_properties=(spec)
|
|
3867
|
+
sheet if @current_sheet.nil?
|
|
3868
|
+
if spec.nil?
|
|
3869
|
+
@current_sheet_properties.delete(:full_calc_on_load)
|
|
3870
|
+
@current_sheet_calc_pr = nil
|
|
3871
|
+
else
|
|
3872
|
+
pr = spec.is_a?(Hash) ? spec.dup : {}
|
|
3873
|
+
@current_sheet_properties[:full_calc_on_load] = pr[:full_calc_on_load] unless pr[:full_calc_on_load].nil?
|
|
3874
|
+
@current_sheet_calc_pr = pr
|
|
3875
|
+
end
|
|
3876
|
+
spec
|
|
3877
|
+
end
|
|
3878
|
+
|
|
3879
|
+
# @deprecated Use {#sheet_calc_properties} instead. Will be removed in 0.2.0.
|
|
3880
|
+
#: (?Hash[Symbol, untyped]? spec, ?full_calc_on_load: bool?, **untyped opts) -> (Elements::SheetCalcProperties | Hash[Symbol, untyped] | nil)
|
|
3881
|
+
def sheet_calc_pr(spec = OMITTED, full_calc_on_load: nil, **opts)
|
|
3882
|
+
warn "[DEPRECATION] #sheet_calc_pr is deprecated; use #sheet_calc_properties instead.", uplevel: 1
|
|
3883
|
+
sheet_calc_properties(spec, full_calc_on_load: full_calc_on_load, **opts)
|
|
3884
|
+
end
|
|
3885
|
+
|
|
3886
|
+
# @deprecated Use {#sheet_calc_properties} instead. Will be removed in 0.2.0.
|
|
3887
|
+
#: (?Hash[Symbol, untyped]? spec, ?full_calc_on_load: bool?, **untyped opts) -> (Elements::SheetCalcProperties | Hash[Symbol, untyped] | nil)
|
|
3888
|
+
def calc_pr(spec = OMITTED, full_calc_on_load: nil, **opts)
|
|
3889
|
+
warn "[DEPRECATION] #calc_pr is deprecated; use #sheet_calc_properties instead.", uplevel: 1
|
|
3890
|
+
sheet_calc_properties(spec, full_calc_on_load: full_calc_on_load, **opts)
|
|
3891
|
+
end
|
|
3892
|
+
|
|
3893
|
+
# @deprecated Use {#sheet_calc_properties=} instead. Will be removed in 0.2.0.
|
|
3894
|
+
#: (Hash[Symbol, untyped]? spec) -> Hash[Symbol, untyped]?
|
|
3895
|
+
def sheet_calc_pr=(spec)
|
|
3896
|
+
warn "[DEPRECATION] #sheet_calc_pr= is deprecated; use #sheet_calc_properties= instead.", uplevel: 1
|
|
3897
|
+
self.sheet_calc_properties = spec
|
|
3898
|
+
end
|
|
3899
|
+
|
|
3900
|
+
# @deprecated Use {#sheet_calc_properties=} instead. Will be removed in 0.2.0.
|
|
3901
|
+
#: (Hash[Symbol, untyped]? spec) -> Hash[Symbol, untyped]?
|
|
3902
|
+
def calc_pr=(spec)
|
|
3903
|
+
warn "[DEPRECATION] #calc_pr= is deprecated; use #sheet_calc_properties= instead.", uplevel: 1
|
|
3904
|
+
self.sheet_calc_properties = spec
|
|
3905
|
+
end
|
|
2519
3906
|
|
|
2520
3907
|
# --- Workbook-Level Methods ---
|
|
2521
3908
|
|
|
@@ -2523,19 +3910,36 @@ module Xlsxrb
|
|
|
2523
3910
|
#
|
|
2524
3911
|
# @param name [String] The defined name.
|
|
2525
3912
|
# @param value [Object, nil] The formula or value expression.
|
|
2526
|
-
# @param sheet [String, nil]
|
|
3913
|
+
# @param sheet [String, nil] Reference sheet name.
|
|
3914
|
+
# @param scope [String, Symbol, nil] Local scope sheet name or :workbook.
|
|
2527
3915
|
# @param hidden [Boolean] Whether the defined name is hidden.
|
|
2528
|
-
# @param
|
|
3916
|
+
# @param column [Integer, String, nil] Deprecated alias for columns.
|
|
3917
|
+
# @param columns [Integer, String, nil] Column index or letter for coordinate-based reference.
|
|
3918
|
+
# @param col [Integer, String, nil] Deprecated alias for column.
|
|
3919
|
+
# @param row [Integer, Range, nil] Deprecated alias for rows.
|
|
2529
3920
|
# @param rows [Integer, Range, nil] Row or row range (1-based) for coordinate-based reference.
|
|
2530
3921
|
# @param range [String, nil] Cell range reference.
|
|
3922
|
+
# @param ref_sheet [String, nil] Deprecated alias for sheet.
|
|
3923
|
+
# @param local [Boolean] Deprecated alias for scope.
|
|
2531
3924
|
# @return [void]
|
|
2532
3925
|
# @api public
|
|
2533
|
-
#: (String name, ?untyped value, ?sheet: String?, ?hidden: bool, ?col: untyped, ?rows: untyped, ?range: untyped, ?ref_sheet: String?, ?local: bool) -> void
|
|
2534
|
-
def defined_name(name, value = nil, sheet: nil, hidden: false, col: nil, rows: nil, range: nil, ref_sheet: nil, local: false)
|
|
3926
|
+
#: (String name, ?untyped value, ?sheet: String?, ?scope: (String | Symbol)?, ?hidden: bool, ?column: untyped, ?columns: untyped, ?col: untyped, ?row: untyped, ?rows: untyped, ?range: untyped, ?ref_sheet: String?, ?local: bool) -> void
|
|
3927
|
+
def defined_name(name, value = nil, sheet: nil, scope: nil, hidden: false, column: nil, columns: nil, col: nil, row: nil, rows: nil, range: nil, ref_sheet: nil, local: false)
|
|
3928
|
+
warn "[DEPRECATION] `col:` is deprecated; use `column:` (or `columns:`) instead.", uplevel: 1 if col
|
|
3929
|
+
warn "[DEPRECATION] `ref_sheet:` is deprecated; use `sheet:` for reference sheet and `scope:` for scope instead.", uplevel: 1 if ref_sheet
|
|
3930
|
+
warn "[DEPRECATION] `local:` is deprecated; use `scope:` instead.", uplevel: 1 if local
|
|
3931
|
+
warn "[Xlsxrb DEPRECATION] defined_name keyword column: is deprecated; use columns: instead.", uplevel: 1 unless column.nil?
|
|
3932
|
+
warn "[Xlsxrb DEPRECATION] defined_name keyword row: is deprecated; use rows: instead.", uplevel: 1 unless row.nil?
|
|
2535
3933
|
target_ref_sheet = ref_sheet || sheet
|
|
2536
|
-
|
|
3934
|
+
c_arg = column || columns || col
|
|
3935
|
+
r_arg = row || rows
|
|
3936
|
+
normalized_val = DslHelpers.normalize_defined_name_value(value, sheet: target_ref_sheet, col: c_arg, rows: r_arg, range: range)
|
|
2537
3937
|
entry = { name: name, value: normalized_val, hidden: hidden }
|
|
2538
|
-
local_sheet =
|
|
3938
|
+
local_sheet = if scope
|
|
3939
|
+
scope == :workbook ? nil : scope.to_s
|
|
3940
|
+
elsif sheet || local || ref_sheet
|
|
3941
|
+
sheet
|
|
3942
|
+
end
|
|
2539
3943
|
if local_sheet
|
|
2540
3944
|
# local_sheet_id will be resolved at close time
|
|
2541
3945
|
entry[:local_sheet_name] = local_sheet
|
|
@@ -2543,44 +3947,104 @@ module Xlsxrb
|
|
|
2543
3947
|
@defined_names << entry
|
|
2544
3948
|
end
|
|
2545
3949
|
|
|
2546
|
-
#
|
|
3950
|
+
# Returns workbook-level defined names.
|
|
2547
3951
|
#
|
|
2548
|
-
# @
|
|
3952
|
+
# @return [Array<Elements::DefinedName>]
|
|
3953
|
+
# @api public
|
|
3954
|
+
#: () -> Array[Elements::DefinedName]
|
|
3955
|
+
def defined_names
|
|
3956
|
+
@defined_names.map { |dn| dn.is_a?(Elements::DefinedName) ? dn : Elements::DefinedName.new(**dn) }
|
|
3957
|
+
end
|
|
3958
|
+
|
|
3959
|
+
# Sets or gets the print area for the current or named sheet.
|
|
3960
|
+
#
|
|
3961
|
+
# @param range [String, Object, nil] Cell range (e.g. "A1:G50").
|
|
2549
3962
|
# @param sheet [String, nil] Target sheet name.
|
|
2550
|
-
# @return [void]
|
|
3963
|
+
# @return [String, nil, void]
|
|
2551
3964
|
# @api public
|
|
2552
|
-
#: (
|
|
2553
|
-
def print_area(range, sheet: nil)
|
|
2554
|
-
|
|
2555
|
-
|
|
3965
|
+
#: (?untyped range, ?sheet: String?) -> (String | nil | void)
|
|
3966
|
+
def print_area(range = OMITTED, sheet: nil)
|
|
3967
|
+
return @current_print_area if range.equal?(OMITTED)
|
|
3968
|
+
|
|
3969
|
+
@current_print_area = range
|
|
2556
3970
|
sheet_name = sheet || @current_sheet || "Sheet1"
|
|
2557
|
-
value = "'#{sheet_name}'!#{absolute_range(range)}"
|
|
2558
3971
|
@defined_names.reject! { |dn| dn[:name] == "_xlnm.Print_Area" && dn[:local_sheet_name] == sheet_name }
|
|
2559
|
-
|
|
2560
|
-
|
|
3972
|
+
if range
|
|
3973
|
+
value = "'#{sheet_name}'!#{absolute_range(range)}"
|
|
3974
|
+
defined_name("_xlnm.Print_Area", value, sheet: sheet_name, scope: sheet_name)
|
|
3975
|
+
end
|
|
3976
|
+
nil
|
|
3977
|
+
end
|
|
3978
|
+
|
|
3979
|
+
# Sets the print area for the current worksheet.
|
|
3980
|
+
#
|
|
3981
|
+
# @param range [String, nil] Cell range (e.g. "A1:G50").
|
|
3982
|
+
# @return [String, nil]
|
|
3983
|
+
# @api public
|
|
3984
|
+
#: (String? range) -> String?
|
|
3985
|
+
def print_area=(range)
|
|
3986
|
+
print_area(range)
|
|
3987
|
+
range
|
|
2561
3988
|
end
|
|
2562
3989
|
|
|
2563
|
-
# Sets print titles for the current or named sheet.
|
|
3990
|
+
# Sets or gets print titles for the current or named sheet.
|
|
2564
3991
|
#
|
|
2565
|
-
# @param rows [String, nil] Repeating row range (e.g. "1:2").
|
|
2566
|
-
# @param
|
|
3992
|
+
# @param rows [String, Integer, Range, Object, nil] Repeating row range (e.g. "1:2" or 0-based 0..1).
|
|
3993
|
+
# @param columns [String, Integer, Symbol, Range, Object, nil] Repeating column range (e.g. "A:B" or 0..1).
|
|
3994
|
+
# @param cols [String, Integer, Symbol, Range, Object, nil] Deprecated alias for columns.
|
|
2567
3995
|
# @param sheet [String, nil] Target sheet name.
|
|
2568
|
-
# @return [void]
|
|
3996
|
+
# @return [Elements::PrintTitles, nil, void]
|
|
2569
3997
|
# @api public
|
|
2570
|
-
#: (?rows:
|
|
2571
|
-
def print_titles(rows:
|
|
3998
|
+
#: (?rows: untyped, ?columns: untyped, ?cols: untyped, ?sheet: String?) -> (Elements::PrintTitles | nil | void)
|
|
3999
|
+
def print_titles(rows: OMITTED, columns: OMITTED, cols: OMITTED, sheet: nil)
|
|
4000
|
+
if rows.equal?(OMITTED) && columns.equal?(OMITTED) && cols.equal?(OMITTED)
|
|
4001
|
+
return nil unless @current_print_titles
|
|
4002
|
+
|
|
4003
|
+
return Elements::PrintTitles.new(rows: @current_print_titles[:rows], columns: @current_print_titles[:columns] || @current_print_titles[:cols])
|
|
4004
|
+
end
|
|
4005
|
+
|
|
4006
|
+
warn "[DEPRECATION] `cols:` is deprecated; use `columns:` instead.", uplevel: 1 if cols && !cols.equal?(OMITTED) && columns.equal?(OMITTED)
|
|
4007
|
+
r_val = rows.equal?(OMITTED) ? nil : rows
|
|
4008
|
+
c_val = if !columns.equal?(OMITTED)
|
|
4009
|
+
columns
|
|
4010
|
+
elsif !cols.equal?(OMITTED)
|
|
4011
|
+
cols
|
|
4012
|
+
end
|
|
4013
|
+
@current_print_titles = { rows: r_val, columns: c_val }.compact
|
|
4014
|
+
|
|
4015
|
+
c = DslHelpers.normalize_print_titles_columns(c_val)
|
|
4016
|
+
r = DslHelpers.normalize_print_titles_rows(r_val)
|
|
2572
4017
|
sheet_name = sheet || @current_sheet || "Sheet1"
|
|
2573
4018
|
existing = @defined_names.find { |dn| dn[:name] == "_xlnm.Print_Titles" && dn[:local_sheet_name] == sheet_name }
|
|
2574
|
-
if existing && (
|
|
2575
|
-
|
|
2576
|
-
|
|
4019
|
+
if existing && (r.nil? || c.nil?)
|
|
4020
|
+
c = Regexp.last_match(1).delete("$") if c.nil? && existing[:value] =~ /'[^']*'!\$([A-Za-z]+:\$[A-Za-z]+)/
|
|
4021
|
+
r = Regexp.last_match(1).delete("$") if r.nil? && existing[:value] =~ /'[^']*'!\$([0-9]+:\$[0-9]+)/
|
|
2577
4022
|
end
|
|
2578
4023
|
parts = []
|
|
2579
|
-
parts << "'#{sheet_name}'!$#{
|
|
2580
|
-
parts << "'#{sheet_name}'!$#{
|
|
4024
|
+
parts << "'#{sheet_name}'!$#{c.sub(":", ":$")}" if c
|
|
4025
|
+
parts << "'#{sheet_name}'!$#{r.sub(":", ":$")}" if r
|
|
2581
4026
|
value = parts.join(",")
|
|
2582
4027
|
@defined_names.reject! { |dn| dn[:name] == "_xlnm.Print_Titles" && dn[:local_sheet_name] == sheet_name }
|
|
2583
|
-
defined_name("_xlnm.Print_Titles", value, sheet: sheet_name)
|
|
4028
|
+
defined_name("_xlnm.Print_Titles", value, sheet: sheet_name, scope: sheet_name) unless value.empty?
|
|
4029
|
+
nil
|
|
4030
|
+
end
|
|
4031
|
+
|
|
4032
|
+
# Sets repeating print titles for the current worksheet.
|
|
4033
|
+
#
|
|
4034
|
+
# @param opts [Elements::PrintTitles, Hash, nil] Options with :rows and/or :columns.
|
|
4035
|
+
# @return [Elements::PrintTitles, Hash, nil]
|
|
4036
|
+
# @api public
|
|
4037
|
+
#: (Elements::PrintTitles | Hash[Symbol, untyped] | nil opts) -> (Elements::PrintTitles | Hash[Symbol, untyped] | nil)
|
|
4038
|
+
def print_titles=(opts)
|
|
4039
|
+
if opts.nil?
|
|
4040
|
+
@current_print_titles = nil
|
|
4041
|
+
sheet_name = @current_sheet || "Sheet1"
|
|
4042
|
+
@defined_names.reject! { |dn| dn[:name] == "_xlnm.Print_Titles" && dn[:local_sheet_name] == sheet_name }
|
|
4043
|
+
else
|
|
4044
|
+
h = opts.respond_to?(:to_h) ? opts.to_h : opts
|
|
4045
|
+
print_titles(**h)
|
|
4046
|
+
end
|
|
4047
|
+
opts
|
|
2584
4048
|
end
|
|
2585
4049
|
|
|
2586
4050
|
# Sets repeating title rows for pagination on the current or named sheet.
|
|
@@ -2619,9 +4083,9 @@ module Xlsxrb
|
|
|
2619
4083
|
cols_str = if first.is_a?(String)
|
|
2620
4084
|
first.include?(":") ? first : "#{first}:#{last || first}"
|
|
2621
4085
|
else
|
|
2622
|
-
first_name =
|
|
4086
|
+
first_name = Elements::Cell._column_letter(first)
|
|
2623
4087
|
last_name = if last.is_a?(Integer)
|
|
2624
|
-
|
|
4088
|
+
Elements::Cell._column_letter(last)
|
|
2625
4089
|
elsif last
|
|
2626
4090
|
last.to_s
|
|
2627
4091
|
else
|
|
@@ -2629,17 +4093,39 @@ module Xlsxrb
|
|
|
2629
4093
|
end
|
|
2630
4094
|
"#{first_name}:#{last_name}"
|
|
2631
4095
|
end
|
|
2632
|
-
print_titles(
|
|
4096
|
+
print_titles(columns: cols_str, sheet: sheet)
|
|
2633
4097
|
end
|
|
2634
4098
|
|
|
2635
|
-
# Sets workbook protection.
|
|
4099
|
+
# Sets or returns workbook protection settings.
|
|
2636
4100
|
#
|
|
2637
4101
|
# @param opts [Hash] Protection options.
|
|
4102
|
+
# @return [Elements::WorkbookProtection, nil, void]
|
|
4103
|
+
# @api public
|
|
4104
|
+
#: (**String | Integer | bool | nil opts) -> (Elements::WorkbookProtection | nil)
|
|
4105
|
+
def workbook_protection(**opts)
|
|
4106
|
+
if opts.empty?
|
|
4107
|
+
@workbook_protection ? Elements::WorkbookProtection.new(**@workbook_protection) : nil
|
|
4108
|
+
else
|
|
4109
|
+
@workbook_protection = opts
|
|
4110
|
+
nil
|
|
4111
|
+
end
|
|
4112
|
+
end
|
|
4113
|
+
|
|
4114
|
+
# Sets workbook protection settings.
|
|
4115
|
+
#
|
|
4116
|
+
# @param opts [Hash, Elements::MetadataRecord, nil]
|
|
2638
4117
|
# @return [void]
|
|
2639
4118
|
# @api public
|
|
4119
|
+
#: (untyped opts) -> void
|
|
4120
|
+
def workbook_protection=(opts)
|
|
4121
|
+
@workbook_protection = opts.is_a?(Elements::MetadataRecord) ? opts.to_h : opts
|
|
4122
|
+
end
|
|
4123
|
+
|
|
4124
|
+
# @deprecated Use {#workbook_protection} instead.
|
|
2640
4125
|
#: (**String | Integer | bool | nil opts) -> void
|
|
2641
|
-
def protect_workbook(
|
|
2642
|
-
|
|
4126
|
+
def protect_workbook(...)
|
|
4127
|
+
warn "[DEPRECATION] `protect_workbook` is deprecated; use `workbook_protection` instead.", uplevel: 1
|
|
4128
|
+
workbook_protection(...)
|
|
2643
4129
|
end
|
|
2644
4130
|
|
|
2645
4131
|
# Sets a core document metadata property.
|
|
@@ -2653,6 +4139,15 @@ module Xlsxrb
|
|
|
2653
4139
|
@core_properties[name] = value
|
|
2654
4140
|
end
|
|
2655
4141
|
|
|
4142
|
+
# Returns core document properties.
|
|
4143
|
+
#
|
|
4144
|
+
# @return [Elements::CoreProperties]
|
|
4145
|
+
# @api public
|
|
4146
|
+
#: () -> Elements::CoreProperties
|
|
4147
|
+
def core_properties
|
|
4148
|
+
Elements::CoreProperties.new(**@core_properties)
|
|
4149
|
+
end
|
|
4150
|
+
|
|
2656
4151
|
# Sets an app document property.
|
|
2657
4152
|
#
|
|
2658
4153
|
# @param name [Symbol] Property name.
|
|
@@ -2663,10 +4158,20 @@ module Xlsxrb
|
|
|
2663
4158
|
def app_property(name, value)
|
|
2664
4159
|
# simplecov:disable
|
|
2665
4160
|
# Edge case / untested delegation block
|
|
2666
|
-
|
|
4161
|
+
norm_name = name.to_sym == :application ? :app_name : name.to_sym
|
|
4162
|
+
@app_properties[norm_name] = value
|
|
2667
4163
|
# simplecov:enable
|
|
2668
4164
|
end
|
|
2669
4165
|
|
|
4166
|
+
# Returns application document properties.
|
|
4167
|
+
#
|
|
4168
|
+
# @return [Elements::AppProperties]
|
|
4169
|
+
# @api public
|
|
4170
|
+
#: () -> Elements::AppProperties
|
|
4171
|
+
def app_properties
|
|
4172
|
+
Elements::AppProperties.new(**@app_properties)
|
|
4173
|
+
end
|
|
4174
|
+
|
|
2670
4175
|
# Sets multiple core and/or app properties.
|
|
2671
4176
|
#
|
|
2672
4177
|
# @param core [Hash, nil] Core properties.
|
|
@@ -2699,6 +4204,18 @@ module Xlsxrb
|
|
|
2699
4204
|
# simplecov:enable
|
|
2700
4205
|
end
|
|
2701
4206
|
|
|
4207
|
+
# Returns custom document properties.
|
|
4208
|
+
#
|
|
4209
|
+
# @return [Hash<String, Elements::CustomProperty>]
|
|
4210
|
+
# @api public
|
|
4211
|
+
#: () -> Hash[String, Elements::CustomProperty]
|
|
4212
|
+
def custom_properties
|
|
4213
|
+
@custom_properties.to_h do |cp|
|
|
4214
|
+
prop = cp.is_a?(Elements::CustomProperty) ? cp : Elements::CustomProperty.new(name: (cp[:name] || cp["name"]).to_s, value: cp[:value] || cp["value"], type: cp[:type] || cp["type"] || :string)
|
|
4215
|
+
[prop.name.to_s, prop]
|
|
4216
|
+
end.freeze
|
|
4217
|
+
end
|
|
4218
|
+
|
|
2702
4219
|
# Finalizes and writes all streaming sheet contents to the destination target.
|
|
2703
4220
|
#
|
|
2704
4221
|
# @return [void]
|
|
@@ -2722,6 +4239,7 @@ module Xlsxrb
|
|
|
2722
4239
|
|
|
2723
4240
|
resolved_names = resolve_defined_names(@defined_names, @sheets)
|
|
2724
4241
|
|
|
4242
|
+
@workbook_properties[:active_sheet] = @active_sheet unless @active_sheet.nil?
|
|
2725
4243
|
@workbook_properties[:active_tab] = @active_sheet unless @active_sheet.nil?
|
|
2726
4244
|
@workbook_properties[:first_sheet] = @first_sheet unless @first_sheet.nil?
|
|
2727
4245
|
@workbook_properties[:show_sheet_tabs] = @show_sheet_tabs unless @show_sheet_tabs.nil?
|
|
@@ -2750,7 +4268,7 @@ module Xlsxrb
|
|
|
2750
4268
|
# Explicitly cleans up any resources if not already closed.
|
|
2751
4269
|
#
|
|
2752
4270
|
# @return [void]
|
|
2753
|
-
# @api
|
|
4271
|
+
# @api private
|
|
2754
4272
|
#: () -> void
|
|
2755
4273
|
def cleanup!
|
|
2756
4274
|
if @zip && !@zip.instance_variable_get(:@closed)
|
|
@@ -2798,7 +4316,7 @@ module Xlsxrb
|
|
|
2798
4316
|
unless @current_conditional_formats.empty?
|
|
2799
4317
|
@dxfs ||= []
|
|
2800
4318
|
@current_conditional_formats = @current_conditional_formats.map do |rule|
|
|
2801
|
-
next rule if rule[:format_id]
|
|
4319
|
+
next rule if rule.respond_to?(:dxf_id) ? rule.dxf_id : (rule.is_a?(Hash) && (rule[:dxf_id] || rule[:format_id]))
|
|
2802
4320
|
|
|
2803
4321
|
normalized = rule.dup
|
|
2804
4322
|
dxf = normalized.delete(:dxf) || DslHelpers.extract_dxf_from_rule!(normalized)
|
|
@@ -2809,6 +4327,7 @@ module Xlsxrb
|
|
|
2809
4327
|
@dxfs << dxf
|
|
2810
4328
|
dxf_id = @dxfs.size - 1
|
|
2811
4329
|
end
|
|
4330
|
+
normalized[:dxf_id] = dxf_id
|
|
2812
4331
|
normalized[:format_id] = dxf_id
|
|
2813
4332
|
normalized
|
|
2814
4333
|
end
|