xlsxrb 0.1.18 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +163 -0
  3. data/README.md +34 -11
  4. data/lib/ruby_lsp/xlsxrb/completion_listener.rb +410 -80
  5. data/lib/xlsxrb/chart_builder.rb +251 -386
  6. data/lib/xlsxrb/dsl_helpers.rb +120 -67
  7. data/lib/xlsxrb/elements/cell.rb +37 -157
  8. data/lib/xlsxrb/elements/column.rb +11 -19
  9. data/lib/xlsxrb/elements/coordinate_access.rb +15 -86
  10. data/lib/xlsxrb/elements/image.rb +5 -72
  11. data/lib/xlsxrb/elements/metadata.rb +463 -817
  12. data/lib/xlsxrb/elements/row.rb +27 -145
  13. data/lib/xlsxrb/elements/styles.rb +30 -88
  14. data/lib/xlsxrb/elements/types.rb +6 -99
  15. data/lib/xlsxrb/elements/workbook.rb +19 -126
  16. data/lib/xlsxrb/elements/worksheet.rb +43 -314
  17. data/lib/xlsxrb/ooxml/reader/listeners/core_listeners.rb +4 -1
  18. data/lib/xlsxrb/ooxml/reader/listeners/drawing_listeners.rb +7 -7
  19. data/lib/xlsxrb/ooxml/reader/listeners/feature_listeners.rb +32 -17
  20. data/lib/xlsxrb/ooxml/reader.rb +49 -51
  21. data/lib/xlsxrb/ooxml/styles_parser.rb +26 -2
  22. data/lib/xlsxrb/ooxml/utils.rb +2 -2
  23. data/lib/xlsxrb/ooxml/workbook_parser.rb +0 -1
  24. data/lib/xlsxrb/ooxml/workbook_writer.rb +172 -93
  25. data/lib/xlsxrb/ooxml/worksheet_parser.rb +61 -29
  26. data/lib/xlsxrb/ooxml/worksheet_writer.rb +65 -47
  27. data/lib/xlsxrb/ooxml/writer/drawing_xml.rb +28 -11
  28. data/lib/xlsxrb/ooxml/writer/features_xml.rb +53 -14
  29. data/lib/xlsxrb/ooxml/writer/styles_xml.rb +1 -1
  30. data/lib/xlsxrb/ooxml/writer.rb +105 -41
  31. data/lib/xlsxrb/ooxml/xml_parser.rb +78 -5
  32. data/lib/xlsxrb/ooxml/zip_reader.rb +65 -15
  33. data/lib/xlsxrb/ooxml/zip_writer.rb +119 -30
  34. data/lib/xlsxrb/stream_row.rb +12 -116
  35. data/lib/xlsxrb/stream_sheet.rb +14 -261
  36. data/lib/xlsxrb/stream_writer.rb +623 -1476
  37. data/lib/xlsxrb/style_builder.rb +376 -593
  38. data/lib/xlsxrb/version.rb +1 -1
  39. data/lib/xlsxrb/workbook_builder.rb +192 -226
  40. data/lib/xlsxrb/worksheet_builder.rb +456 -1324
  41. data/lib/xlsxrb.rb +266 -1083
  42. data/sig/generated/xlsxrb/chart_builder.rbs +202 -205
  43. data/sig/generated/xlsxrb/dsl_helpers.rbs +64 -16
  44. data/sig/generated/xlsxrb/elements/cell.rbs +12 -76
  45. data/sig/generated/xlsxrb/elements/column.rbs +0 -7
  46. data/sig/generated/xlsxrb/elements/coordinate_access.rbs +5 -41
  47. data/sig/generated/xlsxrb/elements/image.rbs +3 -29
  48. data/sig/generated/xlsxrb/elements/metadata.rbs +138 -151
  49. data/sig/generated/xlsxrb/elements/row.rbs +10 -53
  50. data/sig/generated/xlsxrb/elements/styles.rbs +1 -39
  51. data/sig/generated/xlsxrb/elements/workbook.rbs +14 -78
  52. data/sig/generated/xlsxrb/elements/worksheet.rbs +5 -121
  53. data/sig/generated/xlsxrb/ooxml/reader/listeners/feature_listeners.rbs +0 -4
  54. data/sig/generated/xlsxrb/ooxml/reader.rbs +0 -3
  55. data/sig/generated/xlsxrb/ooxml/styles_parser.rbs +1 -1
  56. data/sig/generated/xlsxrb/ooxml/utils.rbs +3 -3
  57. data/sig/generated/xlsxrb/ooxml/workbook_writer.rbs +12 -0
  58. data/sig/generated/xlsxrb/ooxml/worksheet_parser.rbs +16 -0
  59. data/sig/generated/xlsxrb/ooxml/worksheet_writer.rbs +5 -3
  60. data/sig/generated/xlsxrb/ooxml/writer/features_xml.rbs +7 -0
  61. data/sig/generated/xlsxrb/ooxml/writer.rbs +20 -14
  62. data/sig/generated/xlsxrb/ooxml/xml_parser.rbs +70 -0
  63. data/sig/generated/xlsxrb/ooxml/zip_reader.rbs +22 -7
  64. data/sig/generated/xlsxrb/ooxml/zip_writer.rbs +26 -1
  65. data/sig/generated/xlsxrb/stream_row.rbs +7 -42
  66. data/sig/generated/xlsxrb/stream_sheet.rbs +1 -158
  67. data/sig/generated/xlsxrb/stream_writer.rbs +457 -976
  68. data/sig/generated/xlsxrb/style_builder.rbs +206 -242
  69. data/sig/generated/xlsxrb/workbook_builder.rbs +84 -132
  70. data/sig/generated/xlsxrb/worksheet_builder.rbs +309 -685
  71. data/sig/generated/xlsxrb.rbs +43 -190
  72. data/sig/rexml.rbs +8 -0
  73. metadata +3 -5
  74. data/lib/xlsxrb/utils.rb +0 -251
  75. data/sig/generated/xlsxrb/utils.rbs +0 -200
@@ -32,19 +32,6 @@ module Xlsxrb
32
32
  #: String?
33
33
  attr_reader :current_sheet
34
34
 
35
- # @return [Boolean] Whether to treat strings starting with formula prefixes as plain text.
36
- #: bool
37
- attr_accessor :escape_formulas
38
-
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
35
  # Returns whether the shared strings table is enabled.
49
36
  #
50
37
  # @return [Boolean]
@@ -54,13 +41,6 @@ module Xlsxrb
54
41
  @shared_strings ? true : false
55
42
  end
56
43
 
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
63
-
64
44
  # @return [Integer] The ZIP deflate compression level (0..9).
65
45
  #: Integer
66
46
  attr_reader :compression_level
@@ -73,22 +53,20 @@ module Xlsxrb
73
53
  #
74
54
  # @param target [String, IO, StringIO] Destination file path or writable IO stream.
75
55
  # @param strict_excel_mode [Boolean] Whether to enforce Microsoft Excel specification limits.
76
- # @param escape_formulas [Boolean] Whether to treat strings starting with formula prefixes as plain text.
77
56
  # @param default_font [Hash, nil] Optional default font options (e.g. `{ name: "Arial", size: 12 }`).
78
57
  # @param shared_strings [Boolean] Whether to intern strings into a shared strings table (`xl/sharedStrings.xml`).
79
58
  # When set to `false`, strings are written directly as inline strings (`<c t="inlineStr">`), maintaining flat
80
59
  # $O(1)$ constant memory regardless of row count or unique string cardinality. Note that disabling shared strings
81
60
  # may slightly increase archive size (typically 3-5%) on datasets with high repetition.
82
- # @param compression_level [Integer, nil] ZIP deflate compression level (0..9, or Zlib::DEFAULT_COMPRESSION).
83
- # Level 6 is standard. Level 4 accelerates compression by 20-40% with an ~10% size tradeoff,
84
- # recommended for high-throughput streaming exports. Level 0 disables compression (store only).
85
- #: (untyped target, ?strict_excel_mode: bool, ?escape_formulas: bool, ?default_font: untyped?, ?shared_strings: bool, ?compression_level: Integer | nil) -> void
86
- def initialize(target, strict_excel_mode: true, escape_formulas: false, default_font: nil, shared_strings: true, compression_level: Zlib::DEFAULT_COMPRESSION)
61
+ # @param compression_level [Integer, nil] ZIP deflate compression level (0..9, or Zlib::DEFAULT_COMPRESSION
62
+ # for zlib's level 6). Defaults to {Xlsxrb::DEFAULT_COMPRESSION_LEVEL}. Higher levels write smaller files more slowly;
63
+ # level 0 stores entries without compression. See docs/adr/0009-default-zip-compression-level.md.
64
+ #: (untyped target, ?strict_excel_mode: bool, ?default_font: untyped?, ?shared_strings: bool, ?compression_level: Integer | nil) -> void
65
+ def initialize(target, strict_excel_mode: true, default_font: nil, shared_strings: true, compression_level: DEFAULT_COMPRESSION_LEVEL)
87
66
  @target = target
88
67
  @strict_excel_mode = strict_excel_mode
89
- @escape_formulas = escape_formulas ? true : false
90
68
  @shared_strings = shared_strings ? true : false
91
- @compression_level = compression_level || Zlib::DEFAULT_COMPRESSION
69
+ @compression_level = compression_level || DEFAULT_COMPRESSION_LEVEL
92
70
  @io = target.is_a?(String) ? File.open(target, "wb") : target
93
71
  @owns_io = target.is_a?(String)
94
72
  @zip = Ooxml::ZipWriter.new(@io, compression_level: @compression_level)
@@ -149,8 +127,8 @@ module Xlsxrb
149
127
  @styles = {} # { style_name => StyleBuilder }
150
128
  @style_writer = Ooxml::Writer.new(default_font: default_font)
151
129
  @style_name_to_id = {}
152
- style("__xlsxrb_date", number_format: "yyyy-mm-dd")
153
- style("__xlsxrb_time", number_format: "yyyy-mm-dd hh:mm:ss")
130
+ style("__xlsxrb_date", number_format: DslHelpers::DATE_NUMBER_FORMAT)
131
+ style("__xlsxrb_time", number_format: DslHelpers::TIME_NUMBER_FORMAT)
154
132
  # Workbook-level settings
155
133
  @defined_names = []
156
134
  @core_properties = {}
@@ -169,119 +147,50 @@ module Xlsxrb
169
147
  # @param name_or_index [String, Symbol, Integer, nil] Sheet name or 0-based sheet index.
170
148
  # @return [String, Symbol, Integer, nil]
171
149
  # @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.
150
+ # Active worksheet tab in the workbook window.
176
151
  # @return [String, Symbol, Integer, nil]
177
152
  # @api public
178
- #: (?String | Symbol | Integer | nil name_or_index) -> (String | Symbol | Integer | nil)
179
- def active_sheet(name_or_index = OMITTED)
180
- if name_or_index.equal?(OMITTED)
181
- @active_sheet
182
- else
183
- @active_sheet = name_or_index
184
- end
185
- end
186
- # @deprecated Use {#active_sheet} instead. Will be removed in 0.2.0.
187
- alias active_tab active_sheet
153
+ attr_accessor :active_sheet #: (String | Symbol | Integer | nil)
188
154
 
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.
155
+ # First sheet tab visible in the sheet tab scroll area.
192
156
  # @return [String, Symbol, Integer, nil]
193
157
  # @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=
197
-
198
- # Gets or sets the first sheet tab visible in the sheet tab scroll area.
199
- #
200
- # @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#first_sheet=} instead.
201
- # @param name_or_index [String, Symbol, Integer, nil] Sheet name or 0-based sheet index.
202
- # @return [String, Symbol, Integer, nil]
203
- # @api public
204
- #: (?String | Symbol | Integer | nil name_or_index) -> (String | Symbol | Integer | nil)
205
- def first_sheet(name_or_index = OMITTED)
206
- if name_or_index.equal?(OMITTED)
207
- @first_sheet
208
- else
209
- @first_sheet = name_or_index
210
- end
211
- end
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)
219
-
220
- # Gets or sets whether sheet tabs are visible in the workbook window.
221
- #
222
- # @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#show_sheet_tabs=} instead.
223
- # @param visible [Boolean, nil]
224
- # @return [Boolean, nil]
225
- # @api public
226
- #: (?bool? visible) -> bool?
227
- def show_sheet_tabs(visible = OMITTED)
228
- if visible.equal?(OMITTED)
229
- @show_sheet_tabs
230
- else
231
- @show_sheet_tabs = visible
232
- end
233
- end
158
+ attr_accessor :first_sheet #: (String | Symbol | Integer | nil)
234
159
 
235
160
  # Sets whether sheet tabs are visible in the workbook window.
236
- #
237
161
  # @param visible [Boolean, nil]
238
162
  # @return [Boolean, nil]
239
163
  # @api public
240
- attr_writer :show_sheet_tabs #: bool?
164
+ attr_writer :show_sheet_tabs #: (bool?) -> bool?
241
165
 
242
- # Gets or sets the ratio between the sheet tabs bar and the horizontal scroll bar (0-1000).
243
- #
244
- # @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#tab_ratio=} instead.
245
- # @param ratio [Integer, nil]
246
- # @return [Integer, nil]
166
+ # Returns whether sheet tabs are visible in the workbook window.
167
+ # @return [Boolean]
247
168
  # @api public
248
- #: (?Integer? ratio) -> Integer?
249
- def tab_ratio(ratio = OMITTED)
250
- if ratio.equal?(OMITTED)
251
- @tab_ratio
252
- else
253
- @tab_ratio = ratio
254
- end
169
+ #: () -> bool
170
+ def show_sheet_tabs?
171
+ @show_sheet_tabs != false
255
172
  end
256
173
 
257
- # Sets the ratio between the sheet tabs bar and the horizontal scroll bar (0-1000).
258
- #
259
- # @param ratio [Integer, nil]
174
+ # Ratio between the sheet tabs bar and the horizontal scroll bar (0-1000).
260
175
  # @return [Integer, nil]
261
176
  # @api public
262
- attr_writer :tab_ratio #: Integer?
177
+ attr_accessor :tab_ratio #: Integer?
263
178
 
264
- # Sets a workbook property.
179
+ # Configures or queries workbook-level properties.
265
180
  #
266
- # @note **SECURITY WARNING:** If you set `:update_links` to anything other than `"never"`,
267
- # you may expose end-users to malicious external reference vulnerabilities (e.g., CSV/DDE Injection)
268
- # when they open the generated Excel file. Ensure you fully trust the exported data.
269
- #
270
- # @param name [Symbol] Property name (e.g. :update_links).
271
- # @param value [String, Integer, Boolean] Property value.
272
- # @return [void]
273
- #: (Symbol name, String | Integer | bool value) -> void
274
- def workbook_property(name, value)
275
- @workbook_properties[name] = value
276
- end
277
-
278
- # Returns workbook-level properties.
181
+ # When called with no arguments, returns the {Elements::WorkbookProperties} value object.
182
+ # When called with keyword options, configures properties and returns nil.
279
183
  #
280
- # @return [Elements::WorkbookProperties]
184
+ # @param opts [Hash] Workbook properties map.
185
+ # @return [Elements::WorkbookProperties, void]
281
186
  # @api public
282
187
  #: () -> Elements::WorkbookProperties
283
- def workbook_properties
284
- Elements::WorkbookProperties.new(**@workbook_properties)
188
+ #: (**untyped opts) -> void
189
+ def workbook_properties(**opts)
190
+ return Elements::WorkbookProperties.new(**@workbook_properties) if opts.empty?
191
+
192
+ @workbook_properties.merge!(opts)
193
+ nil
285
194
  end
286
195
 
287
196
  # Sets workbook-level properties.
@@ -291,7 +200,9 @@ module Xlsxrb
291
200
  # @api public
292
201
  #: (untyped props) -> void
293
202
  def workbook_properties=(props)
294
- @workbook_properties = props.is_a?(Elements::MetadataRecord) ? props.to_h : props
203
+ h = props.respond_to?(:to_h) ? props.to_h : (props || {})
204
+ @workbook_properties = h.transform_keys(&:to_sym)
205
+ nil
295
206
  end
296
207
 
297
208
  # Defines or configures a named cell style.
@@ -326,8 +237,6 @@ module Xlsxrb
326
237
  def default_font(name = nil, size = nil, **opts)
327
238
  @style_writer.default_font(name, size, **opts)
328
239
  end
329
- # @deprecated Use {#default_font} instead. Will be removed in 0.2.0.
330
- alias set_default_font default_font
331
240
 
332
241
  # Creates an {Elements::Formula} object.
333
242
  # @api public
@@ -375,19 +284,14 @@ module Xlsxrb
375
284
  @sheet_name = sheet_name
376
285
  end
377
286
 
378
- # Sets or configures the workbook-wide default font.
287
+ # Returns the worksheet name.
379
288
  #
380
- # @param name [String, Hash, nil] Font name or font options Hash.
381
- # @param size [Float, Integer, nil] Font size in points.
382
- # @param opts [Hash] Additional font options.
383
- # @return [void]
289
+ # @return [String]
384
290
  # @api public
385
- #: (?String | Hash[Symbol, untyped]? name, ?Float | Integer | nil size, **untyped opts) -> void
386
- def default_font(...)
387
- @writer.default_font(...)
291
+ #: () -> String
292
+ def name
293
+ @sheet_name
388
294
  end
389
- # @deprecated Use {#default_font} instead. Will be removed in 0.2.0.
390
- alias set_default_font default_font
391
295
 
392
296
  # Creates an {Elements::Formula} object.
393
297
  # @api public
@@ -424,58 +328,6 @@ module Xlsxrb
424
328
  Xlsxrb.cell_error(...)
425
329
  end
426
330
 
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
-
445
- # Returns the list of worksheet names created in this workbook so far.
446
- #
447
- # @return [Array<String>] Worksheet names.
448
- # @api public
449
- #: () -> Array[String]
450
- def sheet_names
451
- @writer.sheet_names
452
- end
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
-
479
331
  # Defines or configures a named cell style on the active sheet.
480
332
  #
481
333
  # @example
@@ -499,16 +351,10 @@ module Xlsxrb
499
351
  # @example Merge with cell reference string
500
352
  # s.merge("A1:C1")
501
353
  #
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").
504
- # @param row [Integer, nil] 0-based row index.
505
- # @param col_start [Integer, String, nil] 0-based start column index or letter.
506
- # @param col_end [Integer, String, nil] 0-based end column index or letter.
507
- # @param row_start [Integer, nil] 0-based start row index.
508
- # @param row_end [Integer, nil] 0-based end row index.
354
+ # @param range [String] The cell range (e.g. "A1:B2").
509
355
  # @return [void]
510
356
  # @api public
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
357
+ #: (String range) -> void
512
358
  def merge(...)
513
359
  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
514
360
 
@@ -518,37 +364,24 @@ module Xlsxrb
518
364
  # Adds a drawing shape to the sheet.
519
365
  #
520
366
  # @example
521
- # s.shape(preset: "ellipse", text: "Circle", from_col: 1, from_row: 1, to_col: 4, to_row: 5)
367
+ # s.shape(preset: "ellipse", text: "Circle", from_column: 1, from_row: 1, to_column: 4, to_row: 5)
522
368
  #
523
369
  # @param preset [String] Preset shape type (e.g. "rect", "ellipse").
524
370
  # @param text [String, nil] Shape label text.
525
371
  # @param from_column [Integer, nil] Starting column index (0-based).
526
- # @param from_col [Integer, nil] Deprecated alias for from_column.
527
372
  # @param from_row [Integer] Starting row index (0-based).
528
373
  # @param to_column [Integer, nil] Ending column index (0-based).
529
- # @param to_col [Integer, nil] Deprecated alias for to_column.
530
374
  # @param to_row [Integer] Ending row index (0-based).
531
375
  # @param opts [Hash] Additional shape formatting options.
532
376
  # @return [void]
533
377
  # @api public
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
378
+ #: (?preset: String, ?text: String?, ?from_column: Integer?, ?from_row: Integer, ?to_column: Integer?, ?to_row: Integer, **untyped opts) -> void
535
379
  def shape(...)
536
380
  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
537
381
 
538
382
  @writer.shape(...)
539
383
  end
540
384
 
541
- # simplecov:disable
542
- # Edge case / untested delegation block
543
- # @api private
544
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
545
- def internal_sheet_setup(...)
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
547
-
548
- @writer.internal_sheet_setup(...)
549
- end
550
- # simplecov:enable
551
-
552
385
  # Appends a row of cells to the active sheet.
553
386
  #
554
387
  # @example Write an array of values
@@ -565,27 +398,14 @@ module Xlsxrb
565
398
  # @param custom_height [Boolean] Whether to flag as custom height.
566
399
  # @param outline_level [Integer, nil] Grouping/outline level (0 - 7).
567
400
  # @param collapsed [Boolean] Whether the row is collapsed.
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.
570
401
  # @return [void]
571
402
  # @api public
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)
403
+ #: (Array[untyped] | Hash[untyped, untyped] values, ?cell_styles: untyped, ?row_style: untyped, ?height: Float | Integer | nil, ?hidden: bool, ?custom_height: bool, ?collapsed: bool, ?outline_level: Integer | nil) -> void
404
+ def row(values, cell_styles: nil, row_style: nil, height: nil, hidden: false, custom_height: false, collapsed: false, outline_level: nil)
574
405
  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
575
406
 
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
407
  @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)
586
408
  end
587
- # @deprecated Use {#row} instead. Will be removed in 0.2.0.
588
- alias add_row row
589
409
 
590
410
  # Appends a row to the worksheet and returns self for chaining.
591
411
  #
@@ -603,9 +423,6 @@ module Xlsxrb
603
423
 
604
424
  # Advances the row cursor by count without writing empty row elements.
605
425
  #
606
- # @example Skip one row
607
- # s.skip_row
608
- #
609
426
  # @example Skip multiple rows
610
427
  # s.skip_rows(3)
611
428
  #
@@ -618,8 +435,6 @@ module Xlsxrb
618
435
 
619
436
  @writer.skip_rows(count)
620
437
  end
621
- # @deprecated Use {#skip_rows} instead. Will be removed in 0.2.0.
622
- alias skip_row skip_rows
623
438
 
624
439
  # Configures column width and properties.
625
440
  #
@@ -659,12 +474,6 @@ module Xlsxrb
659
474
 
660
475
  @writer.group_columns(...)
661
476
  end
662
- # @deprecated Use {#group_columns} instead. Will be removed in 0.2.0.
663
- alias group_column group_columns
664
- # @deprecated Use {#group_columns} instead. Will be removed in 0.2.0.
665
- alias group_cols group_columns
666
- # @deprecated Use {#group_columns} instead. Will be removed in 0.2.0.
667
- alias group_col group_columns
668
477
 
669
478
  # Groups multiple rows with outline hierarchy with a block.
670
479
  #
@@ -687,30 +496,25 @@ module Xlsxrb
687
496
  @writer.group_rows(rows, level: level, collapsed: collapsed, hidden: hidden)
688
497
  end
689
498
  end
690
- # @deprecated Use {#group_rows} instead. Will be removed in 0.2.0.
691
- alias group_row group_rows
692
499
 
693
- # Configures worksheet-level outline and grouping view properties.
500
+ # Configures or queries worksheet-level outline and grouping view properties.
694
501
  #
695
502
  # @param summary_below [Boolean, nil] Summary rows below detail rows.
696
503
  # @param summary_right [Boolean, nil] Summary columns to the right of detail columns.
697
504
  # @param show_outline_symbols [Boolean, nil] Outline symbols visible.
698
- # @param show_symbols [Boolean, nil] Deprecated alias for show_outline_symbols.
699
505
  # @param apply_styles [Boolean, nil] Automatic styles applied.
700
506
  # @param opts [Hash] Additional options.
701
- # @return [void]
507
+ # @return [Hash<Symbol, untyped>, void]
702
508
  # @api public
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)
509
+ #: () -> Hash[Symbol, untyped]
510
+ #: (?summary_below: bool?, ?summary_right: bool?, ?show_outline_symbols: bool?, ?apply_styles: bool?, **untyped opts) -> void
511
+ def outline_properties(...)
705
512
  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
706
513
 
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)
514
+ @writer.outline_properties(...)
709
515
  end
710
- # @deprecated Use {#outline_properties} instead. Will be removed in 0.2.0.
711
- alias outline_pr outline_properties
712
516
 
713
- # Sets worksheet outline and grouping view properties.
517
+ # Sets worksheet-level outline and grouping view properties.
714
518
  #
715
519
  # @param opts [Hash] Outline properties.
716
520
  # @return [void]
@@ -721,13 +525,12 @@ module Xlsxrb
721
525
 
722
526
  @writer.outline_properties = opts
723
527
  end
724
- alias outline_pr= outline_properties=
725
528
 
726
529
  # Adds a chart to the active sheet.
727
530
  #
728
531
  # @example
729
532
  # s.chart(:bar) do |chart_builder|
730
- # chart_builder.title("Quarterly Sales")
533
+ # chart_builder.title = "Quarterly Sales"
731
534
  # chart_builder.series(values: "Sheet1!$B$2:$B$5", categories: "Sheet1!$A$2:$A$5", name: "Revenue")
732
535
  # end
733
536
  #
@@ -766,19 +569,15 @@ module Xlsxrb
766
569
  @writer.hyperlink(...)
767
570
  end
768
571
 
769
- # Sets the auto-filter range on the active sheet.
770
- #
771
- # @example
772
- # s.auto_filter("A1:D100")
572
+ # Returns the auto-filter range on the active sheet, or nil if none.
773
573
  #
774
- # @param range [String, nil] The cell range (e.g. "A1:D10").
775
- # @return [void]
574
+ # @return [String, nil]
776
575
  # @api public
777
- #: (String? range) -> void
778
- def auto_filter(...)
576
+ #: () -> String?
577
+ def auto_filter
779
578
  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
780
579
 
781
- @writer.auto_filter(...)
580
+ @writer.auto_filter
782
581
  end
783
582
 
784
583
  # Sets the auto-filter range on the active sheet.
@@ -802,36 +601,37 @@ module Xlsxrb
802
601
  # @param filter [Hash] Values or filter specification hash.
803
602
  # @return [void]
804
603
  # @api public
805
- #: (Integer | String | Symbol col_id, Hash[untyped, untyped] filter) -> void
604
+ #: (Integer | String | Symbol col_id, (Hash[untyped, untyped] | Array[untyped]) filter) -> void
806
605
  def filter_column(...)
807
606
  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
808
607
 
809
608
  @writer.filter_column(...)
810
609
  end
811
610
 
812
- # Configures sort state on a range.
611
+ # Configures or queries sort state on a range.
813
612
  #
814
- # @example
815
- # s.sort_state("A1:A10", [{ ref: "A1:A10", descending: true }])
613
+ # When called with no arguments, returns the {Elements::SortState} value object.
614
+ # When called with arguments, updates sort state and returns nil.
816
615
  #
817
- # @param ref [String] The range to sort.
818
- # @param sort_conditions [Array<Hash>] Sort conditions array.
616
+ # @param ref [String, nil] The range to sort.
617
+ # @param sort_conditions [Array<Hash>, nil] Sort conditions array.
819
618
  # @param opts [Hash] Additional sort options.
820
- # @return [void]
619
+ # @return [Elements::SortState, nil, void]
821
620
  # @api public
822
- #: (String ref, Array[Hash[untyped, untyped]] sort_conditions, **untyped opts) -> void
621
+ #: () -> Elements::SortState?
622
+ #: (?String? ref, ?Array[Hash[untyped, untyped]]? sort_conditions, **untyped opts) -> void
823
623
  def sort_state(...)
824
624
  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
825
625
 
826
626
  @writer.sort_state(...)
827
627
  end
828
628
 
829
- # Sets column sort state for the sheet.
629
+ # Sets sort state configuration for the active sheet.
830
630
  #
831
631
  # @param opts [Elements::SortState, Hash, nil] Sort state options.
832
632
  # @return [void]
833
633
  # @api public
834
- #: (untyped opts) -> void
634
+ #: (Elements::SortState | Hash[Symbol, untyped] | nil opts) -> void
835
635
  def sort_state=(opts)
836
636
  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
637
 
@@ -845,8 +645,8 @@ module Xlsxrb
845
645
  #
846
646
  # @example Block syntax
847
647
  # s.data_validation("B2:B100") do |dv|
848
- # dv.type :list
849
- # dv.formula1 '"High,Medium,Low"'
648
+ # dv.type = :list
649
+ # dv.formula1 = '"High,Medium,Low"'
850
650
  # end
851
651
  #
852
652
  # @param range [String, nil] The cell range (e.g. "B2:B10").
@@ -862,13 +662,6 @@ module Xlsxrb
862
662
  @writer.data_validation(...)
863
663
  end
864
664
 
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(...)
870
- end
871
-
872
665
  # Adds conditional formatting to a range.
873
666
  #
874
667
  # @example Highlight values greater than 100
@@ -900,8 +693,8 @@ module Xlsxrb
900
693
  #
901
694
  # @example Block syntax
902
695
  # s.table("A1:C10") do |t|
903
- # t.columns ["ID", "Name", "Total"]
904
- # t.style "TableStyleMedium9"
696
+ # t.columns = ["ID", "Name", "Total"]
697
+ # t.style = "TableStyleMedium9"
905
698
  # end
906
699
  #
907
700
  # @param ref [String, nil] The cell range for the table (e.g. "A1:D10").
@@ -920,17 +713,6 @@ module Xlsxrb
920
713
  @writer.table(...)
921
714
  end
922
715
 
923
- # simplecov:disable
924
- # Edge case / untested delegation block
925
- # @api private
926
- #: () -> void
927
- def cleanup!(...)
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
929
-
930
- @writer.cleanup!(...)
931
- end
932
- # simplecov:enable
933
-
934
716
  # Adds a comment to a cell.
935
717
  #
936
718
  # @example
@@ -939,9 +721,10 @@ module Xlsxrb
939
721
  # @param cell [String, Integer] The cell reference (e.g. "A1").
940
722
  # @param text [String] The comment text.
941
723
  # @param author [String] The author name.
724
+ # @param visible [Boolean] Whether the comment is always shown instead of on hover.
942
725
  # @return [void]
943
726
  # @api public
944
- #: (String | Integer cell, String text, ?author: String) -> void
727
+ #: (String | Integer cell, String text, ?author: String, ?visible: bool) -> void
945
728
  def comment(...)
946
729
  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
947
730
 
@@ -953,7 +736,7 @@ module Xlsxrb
953
736
  # @param cell [String, Integer] The cell reference (e.g. "A1").
954
737
  # @param text [String] The comment text.
955
738
  # @param author [String] The author name.
956
- # @param opts [Hash] Options: timestamp, id, parent_id, done, user_id, provider_id.
739
+ # @param visible [Boolean] Whether the comment is always shown instead of on hover. # @param opts [Hash] Options: timestamp, id, parent_id, done, user_id, provider_id.
957
740
  # @return [void]
958
741
  # @api public
959
742
  #: (String | Integer cell, String text, ?author: untyped, ?timestamp: untyped, ?id: String?, ?parent_id: String?, ?done: bool?, ?user_id: String?, ?provider_id: String?) -> void
@@ -962,25 +745,21 @@ module Xlsxrb
962
745
 
963
746
  @writer.threaded_comment(...)
964
747
  end
965
- # @deprecated Use {#threaded_comment} instead. Will be removed in 0.2.0.
966
- alias add_threaded_comment threaded_comment
967
748
 
968
749
  # Adds a Pivot Table to the sheet.
969
750
  #
970
751
  # @param source_ref [String] Source data range reference (e.g. "Sheet1!A1:D100").
971
752
  # @param row_fields [Array<String>] Field names for rows.
972
753
  # @param data_fields [Array<String>] Field names for data values.
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.
754
+ # @param column_fields [Array<String>, nil] Field names for columns.
755
+ # @param ref [String, nil] Target top-left cell reference (default: "E1").
977
756
  # @param name [String, nil] Pivot table name.
978
757
  # @param field_names [Array<String>, nil] Override field names.
979
- # @param items [Array, nil] Items configuration.
758
+ # @param items [Hash{Integer => Array}, nil] Items of each field, by 0-based field index.
980
759
  # @param opts [Hash] Additional options.
981
760
  # @return [void]
982
761
  # @api public
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
762
+ #: (String source_ref, row_fields: untyped, data_fields: untyped, ?column_fields: untyped, ?ref: String?, ?name: String?, ?field_names: untyped, ?items: untyped, **untyped opts) -> void
984
763
  def pivot_table(...)
985
764
  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
986
765
 
@@ -1004,161 +783,15 @@ module Xlsxrb
1004
783
  @writer.sparkline_group(...)
1005
784
  end
1006
785
 
1007
- # Adds a single sparkline to the sheet.
1008
- #
1009
- # @example Add a line sparkline
1010
- # s.add_sparkline(location: "F1", range: "A1:E1")
1011
- #
1012
- # @example Add a column sparkline with high/low markers
1013
- # s.add_sparkline(location: "F2", range: "A2:E2", type: :column, high: true, low: true)
1014
- #
1015
- # @example Add a win/loss sparkline
1016
- # s.add_sparkline(location: "F3", range: "A3:E3", type: :win_loss)
1017
- #
1018
- # @param location [String, nil] Target cell for the sparkline (e.g. "F1").
1019
- # @param range [String, nil] Data range for the sparkline (e.g. "A1:E1").
1020
- # @param type [Symbol, String, nil] Sparkline type (:line, :column, :win_loss / :stacked).
1021
- # @param opts [Hash] Additional sparkline options.
1022
- # @deprecated Use {#sparkline_group} instead. Will be removed in 0.2.0.
1023
- # @return [void]
1024
- # @api public
1025
- #: (?location: String?, ?range: String?, ?type: (String | Symbol)?, **untyped opts) -> void
1026
- def add_sparkline(...)
1027
- warn "[DEPRECATION] #add_sparkline is deprecated; use #sparkline_group instead.", uplevel: 1
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
1029
-
1030
- @writer.add_sparkline(...)
1031
- end
1032
-
1033
786
  # Sets workbook-level properties.
1034
787
  #
1035
- # @param name [Symbol] Workbook property name.
1036
- # @param value [String, Integer, Boolean] Property value.
1037
- # @return [void]
1038
- # @api public
1039
- #: (Symbol name, String | Integer | bool value) -> void
1040
- def workbook_property(...)
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
1042
-
1043
- @writer.workbook_property(...)
1044
- end
1045
-
1046
- # Sets or gets the active sheet in the workbook window.
1047
- # If called without arguments on the proxy, marks this sheet as the active sheet.
1048
- #
1049
- # @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#active_sheet=} instead.
1050
- # @param name_or_index [String, Symbol, Integer, nil]
1051
- # @return [String, Symbol, Integer, nil]
1052
- # @api public
1053
- #: (?String | Symbol | Integer | nil name_or_index) -> (String | Symbol | Integer | nil)
1054
- def active_sheet(name_or_index = @sheet_name)
1055
- 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
1056
-
1057
- @writer.active_sheet(name_or_index)
1058
- end
1059
- # @deprecated Use {#active_sheet} instead. Will be removed in 0.2.0.
1060
- alias active_tab active_sheet
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
-
1076
- # Sets or gets the first visible sheet in the tab bar.
788
+ # Gets the sheet visibility state (:visible, :hidden, or :very_hidden).
1077
789
  #
1078
- # @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#first_sheet=} instead.
1079
- # @param name_or_index [String, Symbol, Integer, nil]
1080
- # @return [String, Symbol, Integer, nil]
1081
- # @api public
1082
- #: (?String | Symbol | Integer | nil name_or_index) -> (String | Symbol | Integer | nil)
1083
- def first_sheet(name_or_index = @sheet_name)
1084
- 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
1085
-
1086
- @writer.first_sheet(name_or_index)
1087
- end
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
-
1101
- # Sets or gets whether sheet tabs are visible in the workbook window.
1102
- #
1103
- # @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#show_sheet_tabs=} instead.
1104
- # @param visible [Boolean, nil]
1105
- # @return [Boolean, nil]
1106
- # @api public
1107
- #: (?bool? visible) -> bool?
1108
- def show_sheet_tabs(visible = nil)
1109
- 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
1110
-
1111
- @writer.show_sheet_tabs(visible)
1112
- end
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
-
1126
- # Sets or gets the tab ratio between tab bar and horizontal scrollbar (0-1000).
1127
- #
1128
- # @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#tab_ratio=} instead.
1129
- # @param ratio [Integer, nil]
1130
- # @return [Integer, nil]
1131
- # @api public
1132
- #: (?Integer? ratio) -> Integer?
1133
- def tab_ratio(ratio = nil)
1134
- 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
1135
-
1136
- @writer.tab_ratio(ratio)
1137
- end
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
-
1151
- # Gets or sets the sheet visibility state (:visible, :hidden, or :very_hidden).
1152
- #
1153
- # @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#state=} instead.
1154
- # @param new_state [Symbol, nil] The new state.
1155
790
  # @return [Symbol]
1156
791
  # @api public
1157
- #: (?Symbol? new_state) -> Symbol
1158
- def state(new_state = nil)
1159
- 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
1160
-
1161
- @writer.state(new_state)
792
+ #: () -> Symbol
793
+ def state
794
+ @writer.state
1162
795
  end
1163
796
 
1164
797
  # Sets the sheet visibility state (:visible, :hidden, or :very_hidden).
@@ -1174,18 +807,13 @@ module Xlsxrb
1174
807
  @writer.state
1175
808
  end
1176
809
 
1177
- # Gets or sets the tab color of this worksheet.
810
+ # Gets the tab color of this worksheet.
1178
811
  #
1179
- # @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#tab_color=} instead.
1180
- # @param spec [String, Hash, Symbol, nil] Tab color hex string or hash options.
1181
- # @param opts [Hash] Color keyword arguments (e.g. theme: 1, tint: 0.5).
1182
812
  # @return [String, Hash, nil]
1183
813
  # @api public
1184
- #: (?String | Symbol | Hash[Symbol, untyped] | nil spec, **untyped opts) -> (String | Hash[Symbol, untyped] | nil)
1185
- def tab_color(...)
1186
- 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
-
1188
- @writer.tab_color(...)
814
+ #: () -> (String | Hash[Symbol, untyped] | nil)
815
+ def tab_color
816
+ @writer.tab_color
1189
817
  end
1190
818
 
1191
819
  # Sets the tab color of this worksheet.
@@ -1200,34 +828,17 @@ module Xlsxrb
1200
828
  @writer.tab_color = spec
1201
829
  end
1202
830
 
1203
- # Sets a single sheet property.
831
+ # Configures or queries sheet properties.
1204
832
  #
1205
- # @param name [Symbol, String] Property name.
1206
- # @param value [Object] Property value.
1207
- # @return [void]
833
+ # @param opts [Hash] Keyword options for sheet properties.
834
+ # @return [Elements::SheetProperties, void]
1208
835
  # @api public
1209
- #: (Symbol | String name, untyped value) -> void
1210
- def sheet_property(...)
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
1212
-
1213
- @writer.sheet_property(...)
1214
- end
1215
-
1216
- # Sets sheet properties (e.g. tab color, page setup flags). Accepts kwargs or name/value pair.
1217
- #
1218
- # @example
1219
- # s.sheet_properties(tab_color: "FF0000")
1220
- #
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(...)
836
+ #: () -> Elements::SheetProperties
837
+ #: (**untyped opts) -> void
838
+ def sheet_properties(**opts)
1228
839
  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
840
 
1230
- @writer.sheet_properties(...)
841
+ @writer.sheet_properties(**opts)
1231
842
  end
1232
843
 
1233
844
  # Replaces worksheet properties.
@@ -1247,39 +858,28 @@ module Xlsxrb
1247
858
  # @param name [String] Defined name identifier.
1248
859
  # @param value [Object, nil] Value or formula expression.
1249
860
  # @param hidden [Boolean] Whether the defined name is hidden.
1250
- # @param column [Integer, String, nil] Deprecated alias for columns.
1251
861
  # @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.
1254
- # @param rows [Integer, Range, nil] Row or row range (1-based) for coordinate-based reference.
862
+ # @param rows [Integer, Range, nil] Row or row range (0-based) for coordinate-based reference.
1255
863
  # @param range [String, nil] Cell range reference.
1256
864
  # @param sheet [String, nil] Reference sheet name (defaults to current sheet).
1257
865
  # @param scope [String, Symbol, nil] Scope identifier (:workbook or sheet name).
1258
- # @param local [Boolean] Deprecated alias for scope: :current.
1259
866
  # @return [void]
1260
867
  # @api public
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)
868
+ #: (String name, ?untyped value, ?hidden: bool, ?columns: untyped, ?rows: untyped, ?range: untyped, ?sheet: String?, ?scope: (String | Symbol)?) -> void
869
+ def defined_name(name, value = nil, hidden: false, columns: nil, rows: nil, range: nil, sheet: nil, scope: nil)
1263
870
  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
1264
871
 
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
1271
872
  ref_sheet = sheet || @sheet_name
1272
873
  local_sheet = if scope
1273
874
  scope == :workbook ? nil : scope.to_s
1274
- elsif local
1275
- @sheet_name || sheet
1276
- else
1277
- sheet
1278
875
  end
1279
- @writer.defined_name(name, value, sheet: local_sheet, hidden: hidden, columns: c_arg, rows: r_arg, range: range, ref_sheet: ref_sheet)
876
+ @writer.defined_name(name, value, sheet: ref_sheet, scope: local_sheet, hidden: hidden, columns: columns, rows: rows, range: range)
1280
877
  end
1281
878
 
1282
- # Freezes rows and/or columns for scrolling.
879
+ # Configures or queries freeze panes (<pane state="frozen">).
880
+ #
881
+ # When called with no arguments, returns the {Elements::FreezePane} value object or nil.
882
+ # When called with arguments, configures the freeze pane and returns nil.
1283
883
  #
1284
884
  # @example Freeze top row
1285
885
  # s.freeze_pane(row: 1)
@@ -1289,10 +889,10 @@ module Xlsxrb
1289
889
  #
1290
890
  # @param row [Integer, nil] Number of rows to freeze.
1291
891
  # @param column [Integer, String, nil] Number of columns to freeze.
1292
- # @param col [Integer, String, nil] Deprecated alias for column.
1293
- # @return [void]
892
+ # @return [Elements::FreezePane, nil, void]
1294
893
  # @api public
1295
- #: (?row: Integer | nil, ?column: (Integer | String)?, ?col: (Integer | String)?) -> void
894
+ #: () -> Elements::FreezePane?
895
+ #: (?row: Integer | nil, ?column: (Integer | String)?, ?top_left_cell: String?, ?active_pane: (String | Symbol)?) -> void
1296
896
  def freeze_pane(...)
1297
897
  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
1298
898
 
@@ -1304,27 +904,20 @@ module Xlsxrb
1304
904
  # @param opts [Elements::FreezePane, Hash, nil] Freeze pane options.
1305
905
  # @return [void]
1306
906
  # @api public
1307
- #: (untyped opts) -> void
907
+ #: (Elements::FreezePane | Hash[Symbol, untyped] | nil opts) -> void
1308
908
  def freeze_pane=(opts)
1309
909
  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
1310
910
 
1311
911
  @writer.freeze_pane = opts
1312
912
  end
1313
913
 
1314
- # Sets or gets the print area range for the sheet.
914
+ # Returns the print area range for this worksheet, or nil if none.
1315
915
  #
1316
- # @param range [String, Object, nil] Range reference.
1317
- # @return [String, nil, void]
916
+ # @return [String, nil]
1318
917
  # @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
918
+ #: () -> String?
919
+ def print_area
920
+ @writer.print_area(sheet: @sheet_name)
1328
921
  end
1329
922
 
1330
923
  # Sets the print area for this worksheet.
@@ -1336,25 +929,27 @@ module Xlsxrb
1336
929
  def print_area=(range)
1337
930
  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
931
 
1339
- @writer.print_area(range, sheet: @sheet_name)
1340
- range
932
+ @writer.send(:set_print_area, range, sheet: @sheet_name)
1341
933
  end
1342
934
 
1343
- # Configures or gets repeating title rows and columns for printing.
935
+ # Sets or gets repeating print titles (rows and/or columns) for pagination.
1344
936
  #
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.
937
+ # When called with no arguments, returns the {Elements::PrintTitles} value object or nil.
938
+ # When called with arguments, updates print titles and returns nil.
939
+ #
940
+ # @param rows [String, Integer, Range, nil] Repeating row range (e.g. "1:2").
941
+ # @param columns [String, Integer, Symbol, Range, nil] Repeating column range (e.g. "A:B").
1348
942
  # @return [Elements::PrintTitles, nil, void]
1349
943
  # @api public
1350
- #: (?rows: untyped, ?columns: untyped, ?cols: untyped) -> (Elements::PrintTitles | nil | void)
1351
- def print_titles(rows: OMITTED, columns: OMITTED, cols: OMITTED)
944
+ #: () -> Elements::PrintTitles?
945
+ #: (?rows: (String | Integer | Range[Integer])?, ?columns: (String | Integer | Symbol | Range[untyped])?) -> void
946
+ def print_titles(rows: nil, columns: nil)
1352
947
  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
948
 
1354
- if rows.equal?(OMITTED) && columns.equal?(OMITTED) && cols.equal?(OMITTED)
1355
- @writer.print_titles
949
+ if rows.nil? && columns.nil?
950
+ @writer.print_titles(sheet: @sheet_name)
1356
951
  else
1357
- @writer.print_titles(rows: rows, columns: columns, cols: cols, sheet: @sheet_name)
952
+ @writer.print_titles(rows: rows, columns: columns, sheet: @sheet_name)
1358
953
  end
1359
954
  end
1360
955
 
@@ -1403,16 +998,20 @@ module Xlsxrb
1403
998
  end
1404
999
  # simplecov:enable
1405
1000
 
1406
- # Splits sheet view into panes.
1001
+ # Splits sheet view into panes or queries split pane settings (<pane>).
1002
+ #
1003
+ # When called with no arguments, returns the {Elements::SplitPane} value object or nil.
1004
+ # When called with arguments, configures the split pane and returns nil.
1407
1005
  #
1408
- # @param x_split [Integer] Horizontal split position.
1409
- # @param y_split [Integer] Vertical split position.
1006
+ # @param x_split [Integer, nil] Horizontal split position.
1007
+ # @param y_split [Integer, nil] Vertical split position.
1410
1008
  # @param top_left_cell [String, nil] Top-left visible cell in bottom-right pane.
1411
1009
  # @param active_pane [String, Symbol, nil] Active pane identifier.
1412
1010
  # @param state [String, Symbol, nil] Split state.
1413
- # @return [void]
1011
+ # @return [Elements::SplitPane, nil, void]
1414
1012
  # @api public
1415
- #: (?x_split: Integer, ?y_split: Integer, ?top_left_cell: String?, ?active_pane: (String | Symbol)?, ?state: (String | Symbol)?) -> void
1013
+ #: () -> Elements::SplitPane?
1014
+ #: (?x_split: Integer | nil, ?y_split: Integer | nil, ?top_left_cell: String?, ?active_pane: (String | Symbol)?) -> void
1416
1015
  def split_pane(...)
1417
1016
  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
1418
1017
 
@@ -1424,57 +1023,25 @@ module Xlsxrb
1424
1023
  # @param opts [Elements::SplitPane, Hash, nil] Split pane options.
1425
1024
  # @return [void]
1426
1025
  # @api public
1427
- #: (untyped opts) -> void
1026
+ #: (Elements::SplitPane | Hash[Symbol, untyped] | nil opts) -> void
1428
1027
  def split_pane=(opts)
1429
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
1430
1029
 
1431
1030
  @writer.split_pane = opts
1432
1031
  end
1433
1032
 
1434
- # simplecov:disable
1435
- # Edge case / untested delegation block
1436
- # Sets workbook structure and window protection.
1437
- #
1438
- # @param opts [Hash] Protection options.
1439
- # @return [void]
1440
- # @api public
1441
- #: (**untyped opts) -> void
1442
- def workbook_protection(...)
1443
- @writer.workbook_protection(...)
1444
- end
1445
-
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(...)
1451
- end
1452
- # simplecov:enable
1453
-
1454
- # simplecov:disable
1455
- # Edge case / untested delegation block
1456
- # Sets core metadata property.
1033
+ # Sets or queries the active/selected cell on the sheet (<selection>).
1457
1034
  #
1458
- # @param name [Symbol] Property name.
1459
- # @param value [String, Integer, Time] Property value.
1460
- # @return [void]
1461
- # @api public
1462
- #: (Symbol name, String | Integer | Time value) -> void
1463
- def core_property(...)
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
1465
-
1466
- @writer.core_property(...)
1467
- end
1468
- # simplecov:enable
1469
-
1470
- # Sets the active/selected cell on the sheet.
1035
+ # When called with no arguments, returns the selection ({Elements::Selection}, Array, or nil).
1036
+ # When called with arguments, updates the selection and returns nil.
1471
1037
  #
1472
- # @param active_cell [String] Cell reference (e.g. "A1") or range (e.g. "A1:D10").
1038
+ # @param active_cell [String, nil] Cell reference (e.g. "A1") or range (e.g. "A1:D10").
1473
1039
  # @param sqref [String, nil] Selection range.
1474
1040
  # @param pane [String, Symbol, nil] Pane identifier.
1475
- # @return [void]
1041
+ # @return [Elements::Selection, Array<Elements::Selection>, nil, void]
1476
1042
  # @api public
1477
- #: (String active_cell, ?sqref: String?, ?pane: (String | Symbol)?) -> void
1043
+ #: () -> (Elements::Selection | Array[Elements::Selection])?
1044
+ #: (?String? active_cell, ?sqref: String?, ?pane: (String | Symbol)?) -> void
1478
1045
  def selection(...)
1479
1046
  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
1480
1047
 
@@ -1486,21 +1053,17 @@ module Xlsxrb
1486
1053
  # @param opts [Elements::Selection, Array<Elements::Selection, Hash>, Hash, nil]
1487
1054
  # @return [void]
1488
1055
  # @api public
1489
- #: (untyped opts) -> void
1056
+ #: (Elements::Selection | Array[Elements::Selection | Hash[Symbol, untyped]] | Hash[Symbol, untyped] | nil opts) -> void
1490
1057
  def selection=(opts)
1491
1058
  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
1059
 
1493
1060
  @writer.selection = opts
1494
1061
  end
1495
1062
 
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.
1063
+ # Configures or queries page margins for printing (<pageMargins>).
1064
+ #
1065
+ # When called with no arguments, returns the {Elements::PageMargins} value object or nil.
1066
+ # When called with arguments, configures page margins and returns nil.
1504
1067
  #
1505
1068
  # @param left [Float, nil] Left margin in inches.
1506
1069
  # @param right [Float, nil] Right margin in inches.
@@ -1508,8 +1071,9 @@ module Xlsxrb
1508
1071
  # @param bottom [Float, nil] Bottom margin in inches.
1509
1072
  # @param header [Float, nil] Header margin in inches.
1510
1073
  # @param footer [Float, nil] Footer margin in inches.
1511
- # @return [void]
1074
+ # @return [Elements::PageMargins, nil, void]
1512
1075
  # @api public
1076
+ #: () -> Elements::PageMargins?
1513
1077
  #: (?left: Float | nil, ?right: Float | nil, ?top: Float | nil, ?bottom: Float | nil, ?header: Float | nil, ?footer: Float | nil) -> void
1514
1078
  def page_margins(...)
1515
1079
  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
@@ -1517,26 +1081,30 @@ module Xlsxrb
1517
1081
  @writer.page_margins(...)
1518
1082
  end
1519
1083
 
1520
- # Sets page margins configuration.
1084
+ # Sets or clears page margins configuration.
1521
1085
  #
1522
1086
  # @param opts [Hash, Elements::PageMargins, nil]
1523
1087
  # @return [void]
1524
1088
  # @api public
1525
- #: (untyped opts) -> void
1089
+ #: (Hash[Symbol, untyped] | Elements::PageMargins | nil opts) -> void
1526
1090
  def page_margins=(opts)
1527
1091
  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
1092
 
1529
1093
  @writer.page_margins = opts
1530
1094
  end
1531
1095
 
1532
- # Configures page orientation, paper size, and print setup.
1096
+ # Configures or queries page orientation, paper size, and print setup (<pageSetup>).
1097
+ #
1098
+ # When called with no arguments, returns the {Elements::PageSetup} value object.
1099
+ # When called with keyword arguments, updates page setup and returns nil.
1533
1100
  #
1534
1101
  # @param orientation [String, Symbol, nil] "portrait" or "landscape" (or :portrait, :landscape).
1535
1102
  # @param paper_size [Integer, nil] Paper size index (e.g. 9 for A4, 1 for Letter).
1536
1103
  # @param opts [Hash] Additional options (scale, fit_to_width, fit_to_height).
1537
- # @return [void]
1104
+ # @return [Elements::PageSetup, void]
1538
1105
  # @api public
1539
- #: (?orientation: (String | Symbol)?, ?paper_size: Integer | nil, **untyped opts) -> void
1106
+ #: () -> Elements::PageSetup
1107
+ #: (**untyped opts) -> void
1540
1108
  def page_setup(...)
1541
1109
  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
1542
1110
 
@@ -1548,18 +1116,22 @@ module Xlsxrb
1548
1116
  # @param opts [Hash, Elements::PageSetup]
1549
1117
  # @return [void]
1550
1118
  # @api public
1551
- #: (untyped opts) -> void
1119
+ #: (Hash[Symbol, untyped] | Elements::PageSetup opts) -> void
1552
1120
  def page_setup=(opts)
1553
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
1554
1122
 
1555
1123
  @writer.page_setup = opts
1556
1124
  end
1557
1125
 
1558
- # Configures header and footer text for printing.
1126
+ # Configures or queries header and footer text for printing (<headerFooter>).
1127
+ #
1128
+ # When called with no arguments, returns the {Elements::HeaderFooter} value object.
1129
+ # When called with keyword arguments, updates headers and footers and returns nil.
1559
1130
  #
1560
1131
  # @param opts [Hash] Header and footer specifications.
1561
- # @return [void]
1132
+ # @return [Elements::HeaderFooter, void]
1562
1133
  # @api public
1134
+ #: () -> Elements::HeaderFooter
1563
1135
  #: (**untyped opts) -> void
1564
1136
  def header_footer(...)
1565
1137
  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
@@ -1572,25 +1144,25 @@ module Xlsxrb
1572
1144
  # @param opts [Hash, Elements::HeaderFooter]
1573
1145
  # @return [void]
1574
1146
  # @api public
1575
- #: (untyped opts) -> void
1147
+ #: (Hash[Symbol, untyped] | Elements::HeaderFooter opts) -> void
1576
1148
  def header_footer=(opts)
1577
1149
  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
1150
 
1579
1151
  @writer.header_footer = opts
1580
1152
  end
1581
1153
 
1582
- # Configures print options (e.g. gridlines, headings).
1154
+ # Configures or gets print options (e.g. gridlines, headings).
1155
+ # Configures or queries print options.
1583
1156
  #
1584
- # @param name [Symbol, String, Hash, nil] Print option name or hash.
1585
- # @param value [Object, nil] Print option value.
1586
1157
  # @param opts [Hash] Additional options.
1587
- # @return [void]
1158
+ # @return [Elements::PrintOptions, void]
1588
1159
  # @api public
1589
- #: (?Symbol | String | Hash[Symbol, untyped] | nil name, ?untyped value, **untyped opts) -> void
1590
- def print_options(...)
1160
+ #: () -> Elements::PrintOptions
1161
+ #: (**untyped opts) -> void
1162
+ def print_options(**opts)
1591
1163
  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
1592
1164
 
1593
- @writer.print_options(...)
1165
+ @writer.print_options(**opts)
1594
1166
  end
1595
1167
 
1596
1168
  # Replaces print options.
@@ -1604,44 +1176,15 @@ module Xlsxrb
1604
1176
  @writer.print_options = opts
1605
1177
  end
1606
1178
 
1607
- # simplecov:disable
1608
- # Edge case / untested delegation block
1609
- # Sets document metadata properties (core, app, custom).
1179
+ # Sets or queries sheet-level protection with optional password hashing (<sheetProtection>).
1610
1180
  #
1611
- # @param core [Hash, nil] Core properties (title, creator, subject, etc.).
1612
- # @param app [Hash, nil] App properties (company, manager).
1613
- # @param custom [Hash, nil] Custom properties.
1614
- # @return [void]
1615
- # @api public
1616
- #: (?core: Hash[untyped, untyped]?, ?app: Hash[untyped, untyped]?, ?custom: Hash[untyped, untyped]?) -> void
1617
- def properties(...)
1618
- 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
1619
-
1620
- @writer.properties(...)
1621
- end
1622
- # simplecov:enable
1623
-
1624
- # simplecov:disable
1625
- # Edge case / untested delegation block
1626
- # Sets app metadata property.
1627
- #
1628
- # @param name [Symbol] Property name.
1629
- # @param value [String, Integer, Time] Property value.
1630
- # @return [void]
1631
- # @api public
1632
- #: (Symbol name, String | Integer | Time value) -> void
1633
- def app_property(...)
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
1635
-
1636
- @writer.app_property(...)
1637
- end
1638
- # simplecov:enable
1639
-
1640
- # Sets sheet-level protection with optional password hashing.
1181
+ # When called with no arguments, returns the {Elements::SheetProtection} value object or nil.
1182
+ # When called with keyword arguments, sets sheet protection and returns nil.
1641
1183
  #
1642
1184
  # @param opts [Hash] Protection options.
1643
- # @return [void]
1185
+ # @return [Elements::SheetProtection, nil, void]
1644
1186
  # @api public
1187
+ #: () -> Elements::SheetProtection?
1645
1188
  #: (**untyped opts) -> void
1646
1189
  def sheet_protection(...)
1647
1190
  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
@@ -1654,102 +1197,74 @@ module Xlsxrb
1654
1197
  # @param opts [Elements::SheetProtection, Hash, Boolean, nil]
1655
1198
  # @return [void]
1656
1199
  # @api public
1657
- #: (untyped opts) -> void
1200
+ #: (Elements::SheetProtection | Hash[Symbol, untyped] | bool | nil opts) -> void
1658
1201
  def sheet_protection=(opts)
1659
1202
  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
1660
1203
 
1661
1204
  @writer.sheet_protection = opts
1662
1205
  end
1663
1206
 
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(...)
1669
- end
1670
-
1671
- # simplecov:disable
1672
- # Edge case / untested delegation block
1673
- # Sets custom metadata property.
1207
+ # Returns column configurations defined for this worksheet.
1674
1208
  #
1675
- # @param name [String] Property name.
1676
- # @param value [String, Integer, Float, Boolean, Time] Property value.
1677
- # @param type [Symbol] Value type.
1678
- # @return [void]
1209
+ # @return [Array<Elements::Column>]
1679
1210
  # @api public
1680
- #: (String name, String | Integer | Float | bool | Time value, ?type: ::Symbol) -> void
1681
- def custom_property(...)
1211
+ #: () -> Array[Elements::Column]
1212
+ def columns
1682
1213
  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
1683
1214
 
1684
- @writer.custom_property(...)
1215
+ @writer.columns
1685
1216
  end
1686
- # simplecov:enable
1687
1217
 
1688
1218
  # Inserts an image into the sheet.
1689
1219
  #
1690
1220
  # @param file_data [String] Binary image data or file content.
1691
1221
  # @param ext [String] Image extension ("png", "jpeg", etc.).
1692
1222
  # @param from_column [Integer, nil] Starting column index (0-based).
1693
- # @param from_col [Integer, nil] Deprecated alias for from_column.
1694
1223
  # @param from_row [Integer] Starting row index (0-based).
1695
1224
  # @param to_column [Integer, nil] Ending column index (0-based).
1696
- # @param to_col [Integer, nil] Deprecated alias for to_column.
1697
1225
  # @param to_row [Integer] Ending row index (0-based).
1698
1226
  # @param opts [Hash] Additional anchor and sizing options.
1699
1227
  # @return [void]
1700
1228
  # @api public
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
1229
+ #: (String file_data, ?ext: String, ?from_column: Integer?, ?from_row: Integer, ?to_column: Integer?, ?to_row: Integer, **untyped opts) -> void
1702
1230
  def image(...)
1703
1231
  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
1704
1232
 
1705
1233
  @writer.image(...)
1706
1234
  end
1707
1235
 
1708
- # Configures the worksheet background image (<picture>).
1709
- #
1710
- # @example Set background image from binary data
1711
- # sheet.background_image(png_bytes, ext: "png")
1236
+ # Gets the worksheet background image (<picture>).
1712
1237
  #
1713
- # @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#background_image=} instead.
1714
- # @param file_data [String, Hash, Elements::Image, nil] Image binary data, file path, or image options hash.
1715
- # @param ext [String, nil] Image extension.
1716
- # @param opts [Hash] Additional options.
1717
- # @return [Hash, nil]
1238
+ # @return [Elements::BackgroundImage, nil]
1718
1239
  # @api public
1719
- #: (?untyped file_data, ?ext: String?, **untyped opts) -> Hash[Symbol, untyped]?
1720
- def background_image(...)
1721
- 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
1722
-
1723
- @writer.background_image(...)
1240
+ #: () -> Elements::BackgroundImage?
1241
+ def background_image
1242
+ @writer.background_image
1724
1243
  end
1725
- # @deprecated Use {#background_image} instead. Will be removed in 0.2.0.
1726
- alias background_picture background_image
1727
- # @deprecated Use {#background_image} instead. Will be removed in 0.2.0.
1728
- alias picture background_image
1729
1244
 
1245
+ # Sets the worksheet background image (<picture>).
1246
+ #
1247
+ # @param val [String, Hash, Elements::Image, nil] Image binary data, file path, or image options hash.
1248
+ # @return [untyped]
1249
+ # @api public
1730
1250
  #: (untyped val) -> untyped
1731
1251
  def background_image=(val)
1732
1252
  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
1733
1253
 
1734
1254
  @writer.background_image = val
1735
1255
  end
1736
- # @deprecated Use {#background_image=} instead. Will be removed in 0.2.0.
1737
- alias background_picture= background_image=
1738
- # @deprecated Use {#background_image=} instead. Will be removed in 0.2.0.
1739
- alias picture= background_image=
1740
1256
 
1741
- # Configures sheet view settings (zoom scale, grid lines visibility).
1257
+ # Configures or gets sheet view settings (zoom scale, grid lines visibility).
1742
1258
  #
1743
- # @param name [Symbol, String, Hash, nil] View setting name or hash.
1744
- # @param value [Object, nil] View setting value.
1745
1259
  # @param opts [Hash] Additional options.
1746
- # @return [void]
1260
+ # @return [Elements::SheetView, void]
1747
1261
  # @api public
1748
- #: (?Symbol | String | Hash[Symbol, untyped] | nil name, ?untyped value, **untyped opts) -> void
1749
- def sheet_view(...)
1262
+ #: () -> Elements::SheetView
1263
+ #: (**untyped opts) -> void
1264
+ def sheet_view(**opts)
1750
1265
  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
1751
1266
 
1752
- @writer.sheet_view(...)
1267
+ @writer.sheet_view(**opts)
1753
1268
  end
1754
1269
 
1755
1270
  # Replaces sheet view properties.
@@ -1763,18 +1278,17 @@ module Xlsxrb
1763
1278
  @writer.sheet_view = opts
1764
1279
  end
1765
1280
 
1766
- # Configures sheet format properties (e.g. default_row_height, default_col_width).
1281
+ # Configures or gets sheet format properties (e.g. default_row_height, default_column_width).
1767
1282
  #
1768
- # @param name [Symbol, String, Hash, nil] Property name or hash of properties.
1769
- # @param value [Object, nil] Property value when name is provided.
1770
1283
  # @param opts [Hash] Keyword arguments for sheet format properties.
1771
- # @return [Hash[Symbol, untyped]]
1284
+ # @return [Elements::SheetFormat, void]
1772
1285
  # @api public
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)
1286
+ #: () -> Elements::SheetFormat
1287
+ #: (**untyped opts) -> void
1288
+ def sheet_format(**opts)
1775
1289
  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
1776
1290
 
1777
- @writer.sheet_format(name, value, **opts)
1291
+ @writer.sheet_format(**opts)
1778
1292
  end
1779
1293
 
1780
1294
  # Replaces sheet format properties.
@@ -1801,13 +1315,6 @@ module Xlsxrb
1801
1315
 
1802
1316
  @writer.row_break(...)
1803
1317
  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(...)
1810
- end
1811
1318
  # simplecov:enable
1812
1319
 
1813
1320
  # simplecov:disable
@@ -1823,13 +1330,6 @@ module Xlsxrb
1823
1330
 
1824
1331
  @writer.column_break(...)
1825
1332
  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(...)
1832
- end
1833
1333
  # simplecov:enable
1834
1334
 
1835
1335
  # Adds a protected range to the sheet.
@@ -1846,8 +1346,6 @@ module Xlsxrb
1846
1346
 
1847
1347
  @writer.protected_range(...)
1848
1348
  end
1849
- # @deprecated Use {#protected_range} instead. Will be removed in 0.2.0.
1850
- alias add_protected_range protected_range
1851
1349
 
1852
1350
  # Adds a cell watch to the sheet.
1853
1351
  #
@@ -1860,8 +1358,6 @@ module Xlsxrb
1860
1358
 
1861
1359
  @writer.cell_watch(...)
1862
1360
  end
1863
- # @deprecated Use {#cell_watch} instead. Will be removed in 0.2.0.
1864
- alias add_cell_watch cell_watch
1865
1361
 
1866
1362
  # Adds an ignored error entry to the sheet.
1867
1363
  #
@@ -1870,47 +1366,29 @@ module Xlsxrb
1870
1366
  # @return [void]
1871
1367
  # @api public
1872
1368
  #: (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
1873
- def ignored_error(...)
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
1875
-
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(...)
1369
+ def ignored_error(...)
1370
+ 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
1371
+
1372
+ @writer.ignored_error(...)
1891
1373
  end
1892
1374
 
1893
1375
  # Returns the ignored error entries configured for this sheet.
1894
1376
  #
1895
- # @return [Array<Hash[Symbol, untyped]>]
1377
+ # @return [Array<Elements::IgnoredError>]
1896
1378
  # @api public
1897
- #: () -> Array[Hash[Symbol, untyped]]
1379
+ #: () -> Array[Elements::IgnoredError]
1898
1380
  def ignored_errors
1899
1381
  @writer.ignored_errors
1900
1382
  end
1901
1383
 
1902
- # Gets or sets phonetic (furigana) guide properties for the sheet.
1384
+ # Gets phonetic (furigana) guide properties for the sheet.
1903
1385
  #
1904
- # @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#phonetic_properties=} instead.
1386
+ # @return [Elements::PhoneticProperties, nil]
1905
1387
  # @api public
1906
- #: (?untyped spec, ?font_id: Integer?, ?type: (Symbol | String)?, ?alignment: (Symbol | String)?, **untyped opts) -> (Elements::PhoneticProperties | Hash[Symbol, untyped] | nil)
1907
- def phonetic_properties(...)
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
1909
-
1910
- @writer.phonetic_properties(...)
1388
+ #: () -> Elements::PhoneticProperties?
1389
+ def phonetic_properties
1390
+ @writer.phonetic_properties
1911
1391
  end
1912
- # @deprecated Use {#phonetic_properties} instead. Will be removed in 0.2.0.
1913
- alias phonetic_pr phonetic_properties
1914
1392
 
1915
1393
  # Sets phonetic (furigana) guide properties for the sheet.
1916
1394
  #
@@ -1923,20 +1401,14 @@ module Xlsxrb
1923
1401
 
1924
1402
  @writer.phonetic_properties = spec
1925
1403
  end
1926
- # @deprecated Use {#phonetic_properties=} instead. Will be removed in 0.2.0.
1927
- alias phonetic_pr= phonetic_properties=
1928
1404
 
1929
- # Sets or gets the internal code name of the worksheet.
1405
+ # Gets the internal code name of the worksheet.
1930
1406
  #
1931
- # @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#code_name=} instead.
1932
- # @param val [String, Symbol, nil] The code name.
1933
1407
  # @return [String, nil]
1934
1408
  # @api public
1935
- #: (?String | Symbol | nil val) -> String?
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(...)
1409
+ #: () -> String?
1410
+ def code_name
1411
+ @writer.code_name
1940
1412
  end
1941
1413
 
1942
1414
  # Sets the internal code name of the worksheet.
@@ -1951,31 +1423,13 @@ module Xlsxrb
1951
1423
  @writer.code_name = val
1952
1424
  end
1953
1425
 
1954
- # Configures whether page setup fits content to page width/height.
1955
- # When enabled, optionally sets fit_to_width and/or fit_to_height on page_setup.
1426
+ # Returns whether page setup fits content to page width/height.
1956
1427
  #
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.
1958
- # @param enabled [Boolean, nil] Whether to fit to page.
1959
- # @param width [Integer, nil] Pages wide to fit to.
1960
- # @param height [Integer, nil] Pages tall to fit to.
1961
- # @return [Boolean, void]
1962
- # @api public
1963
- #: (?bool? enabled, ?width: Integer?, ?height: Integer?) -> (bool | void)
1964
- def fit_to_page(enabled = OMITTED, width: nil, height: nil)
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
1966
-
1967
- @writer.fit_to_page(enabled, width: width, height: height)
1968
- end
1969
-
1970
- # @deprecated Use {#fit_to_page} instead. Will be removed in 0.2.0.
1971
1428
  # @return [Boolean]
1972
1429
  # @api public
1973
1430
  #: () -> bool
1974
1431
  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
1432
+ @writer.fit_to_page?
1979
1433
  end
1980
1434
 
1981
1435
  # Sets whether page setup fits content to page width/height.
@@ -1983,25 +1437,20 @@ module Xlsxrb
1983
1437
  # @param enabled [Boolean, nil] Whether to fit to page.
1984
1438
  # @return [Boolean]
1985
1439
  # @api public
1986
- #: (bool? enabled) -> bool?
1440
+ #: (bool? enabled) -> bool??
1987
1441
  def fit_to_page=(enabled)
1988
1442
  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
1443
 
1990
1444
  @writer.fit_to_page = enabled
1991
1445
  end
1992
1446
 
1993
- # Configures worksheet calculation properties (<sheetCalcPr>).
1447
+ # Gets worksheet calculation properties (<sheetCalcPr>).
1994
1448
  #
1995
- # @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#sheet_calc_properties=} instead.
1996
- # @param spec [Hash, nil] Calculation properties hash.
1997
- # @param full_calc_on_load [Boolean, nil] Whether to recalculate when loading.
1998
- # @return [Hash, nil]
1449
+ # @return [Elements::SheetCalcProperties, nil]
1999
1450
  # @api public
2000
- #: (?untyped spec, ?full_calc_on_load: bool?, **untyped opts) -> (Elements::SheetCalcProperties | Hash[Symbol, untyped] | nil)
2001
- def sheet_calc_properties(...)
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
2003
-
2004
- @writer.sheet_calc_properties(...)
1451
+ #: () -> Elements::SheetCalcProperties?
1452
+ def sheet_calc_properties
1453
+ @writer.sheet_calc_properties
2005
1454
  end
2006
1455
 
2007
1456
  # Sets worksheet calculation properties (<sheetCalcPr>).
@@ -2015,34 +1464,6 @@ module Xlsxrb
2015
1464
 
2016
1465
  @writer.sheet_calc_properties = spec
2017
1466
  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
2045
- end
2046
1467
  end
2047
1468
 
2048
1469
  # Returns the list of worksheet names created in this workbook so far.
@@ -2060,16 +1481,15 @@ module Xlsxrb
2060
1481
  #
2061
1482
  # @param name [String, nil] Sheet name (max 31 characters).
2062
1483
  # @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.
1484
+ # @param tab_color [String, Hash, Symbol, nil] Tab color hex string (e.g. "FF0000") or hash options.
1485
+ # @param code_name [String, Symbol, nil] Internal VBA code name of the sheet.
2066
1486
  # @param opts [Hash] Sheet-level configuration.
2067
1487
  # @yield [sheet_proxy]
2068
1488
  # @yieldparam sheet_proxy [WorksheetProxy] The streaming sheet proxy.
2069
1489
  # @return [String] The sheet name.
2070
1490
  # @api public
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)
1491
+ #: (?String? name, ?state: Symbol | String | nil, ?tab_color: String | Hash[Symbol, untyped] | Symbol | nil, ?code_name: String | Symbol | nil, **untyped opts) ?{ (WorksheetProxy) -> void } -> String
1492
+ def sheet(name = nil, state: nil, tab_color: nil, code_name: nil, **opts)
2073
1493
  sheet_count = @sheets.size + (@current_sheet ? 1 : 0)
2074
1494
  name ||= "Sheet#{sheet_count + 1}"
2075
1495
  raise ArgumentError, "Sheet name '#{name}' must be <= 31 characters (Excel limitation)" if @strict_excel_mode && name.length > 31
@@ -2083,11 +1503,9 @@ module Xlsxrb
2083
1503
 
2084
1504
  active = opts.delete(:active)
2085
1505
  state = opts.delete(:state) if opts.key?(:state)
2086
- hidden = opts.delete(:hidden) if opts.key?(:hidden)
1506
+ hidden = opts.delete(:hidden)
2087
1507
  code_name = opts.delete(:code_name) if opts.key?(:code_name)
2088
1508
  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?
2091
1509
  state ||= :hidden if hidden
2092
1510
  state ||= :visible
2093
1511
  state = state.to_sym
@@ -2100,7 +1518,7 @@ module Xlsxrb
2100
1518
  end
2101
1519
  self.tab_color = tab_color if tab_color
2102
1520
  self.code_name = code_name if code_name
2103
- opts.each { |k, v| sheet_properties(k, v) }
1521
+ sheet_properties(**opts) unless opts.empty?
2104
1522
 
2105
1523
  yield WorksheetProxy.new(self, @current_sheet) if block_given?
2106
1524
  @current_sheet
@@ -2142,7 +1560,7 @@ module Xlsxrb
2142
1560
  @current_row_buffer = String.new(capacity: 65_536)
2143
1561
  @current_sheet_io = StringIO.new(@current_row_buffer)
2144
1562
  date1904 = @workbook_properties&.[](:date1904) ? true : false
2145
- @current_row_writer = Ooxml::WorksheetWriter.new(@current_sheet_io, date1904: date1904, escape_formulas: @escape_formulas)
1563
+ @current_row_writer = Ooxml::WorksheetWriter.new(@current_sheet_io, date1904: date1904)
2146
1564
  @current_row_writer.instance_variable_set(:@started, true)
2147
1565
 
2148
1566
  @current_columns = []
@@ -2222,7 +1640,7 @@ module Xlsxrb
2222
1640
  end
2223
1641
 
2224
1642
  date1904 = @workbook_properties&.[](:date1904) ? true : false
2225
- @current_row_writer = Ooxml::WorksheetWriter.new(zip_io, date1904: date1904, escape_formulas: @escape_formulas)
1643
+ @current_row_writer = Ooxml::WorksheetWriter.new(zip_io, date1904: date1904)
2226
1644
  @current_row_writer.start(
2227
1645
  columns: @current_columns,
2228
1646
  sheet_properties: @current_sheet_properties.empty? ? nil : @current_sheet_properties,
@@ -2246,29 +1664,23 @@ module Xlsxrb
2246
1664
  # @param custom_height [Boolean] Whether custom row height is set.
2247
1665
  # @param outline_level [Integer, nil] Grouping/outline level (0 - 7).
2248
1666
  # @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.
2251
1667
  # @return [void]
2252
1668
  # @api public
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)
1669
+ #: (Array[untyped] | Hash[untyped, untyped] values, ?cell_styles: untyped, ?row_style: untyped, ?height: Float | Integer | nil, ?hidden: bool, ?custom_height: bool, ?collapsed: bool, ?outline_level: Integer | nil) -> void
1670
+ def row(values, cell_styles: nil, row_style: nil, height: nil, hidden: false, custom_height: false, collapsed: false, outline_level: nil)
2255
1671
  sheet if @current_sheet.nil?
2256
1672
 
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
-
2266
1673
  row_index = @current_row_index
2267
1674
  DslHelpers.validate_row_bounds!(row_index, height, strict_excel_mode: @strict_excel_mode)
2268
1675
  @current_row_index += 1
2269
1676
 
2270
1677
  values = DslHelpers.normalize_row_values(values)
2271
1678
  cell_styles = DslHelpers.normalize_row_styles(cell_styles)
1679
+ if cell_styles
1680
+ check_style_names!(cell_styles)
1681
+ cell_styles = with_date_style_variants(values, cell_styles)
1682
+ end
1683
+ DslHelpers.check_style_name!(row_style, @style_name_to_id)
2272
1684
 
2273
1685
  if @current_charts && !@current_charts.empty?
2274
1686
  @current_cells ||= {}
@@ -2285,7 +1697,7 @@ module Xlsxrb
2285
1697
 
2286
1698
  row_style_id = if row_style.is_a?(Hash)
2287
1699
  inline_name = "__inline_row_#{row_style.hash}"
2288
- self.style(inline_name, **row_style) unless @style_name_to_id.key?(inline_name)
1700
+ style(inline_name, **row_style) unless @style_name_to_id.key?(inline_name)
2289
1701
  @style_name_to_id[inline_name]
2290
1702
  else
2291
1703
  row_style
@@ -2309,8 +1721,6 @@ module Xlsxrb
2309
1721
  @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)
2310
1722
  start_sheet_entry if !@sheet_entry_started && @current_row_buffer.bytesize >= 65_536
2311
1723
  end
2312
- # @deprecated Use {#row} instead. Will be removed in 0.2.0.
2313
- alias add_row row
2314
1724
 
2315
1725
  # Appends a row to the worksheet and returns self for chaining.
2316
1726
  #
@@ -2328,9 +1738,6 @@ module Xlsxrb
2328
1738
 
2329
1739
  # Advances the row cursor by count without writing empty row elements.
2330
1740
  #
2331
- # @example Skip one row
2332
- # w.skip_row
2333
- #
2334
1741
  # @example Skip multiple rows
2335
1742
  # w.skip_rows(3)
2336
1743
  #
@@ -2344,8 +1751,6 @@ module Xlsxrb
2344
1751
  sheet if @current_sheet.nil?
2345
1752
  @current_row_index += count
2346
1753
  end
2347
- # @deprecated Use {#skip_rows} instead. Will be removed in 0.2.0.
2348
- alias skip_row skip_rows
2349
1754
 
2350
1755
  # Sets column formatting and properties for one or multiple columns.
2351
1756
  #
@@ -2365,6 +1770,7 @@ module Xlsxrb
2365
1770
 
2366
1771
  sheet if @current_sheet.nil?
2367
1772
 
1773
+ DslHelpers.check_style_name!(style, @style_name_to_id)
2368
1774
  style_id = if style.is_a?(Hash)
2369
1775
  inline_name = "__inline_col_#{style.hash}"
2370
1776
  style(inline_name, **style) unless @style_name_to_id.key?(inline_name)
@@ -2402,22 +1808,20 @@ module Xlsxrb
2402
1808
  nil
2403
1809
  end
2404
1810
 
2405
- # Returns column configurations defined for the current worksheet.
1811
+ # Returns column configurations defined for the active worksheet.
2406
1812
  #
2407
1813
  # @return [Array<Elements::Column>]
2408
1814
  # @api public
2409
1815
  #: () -> Array[Elements::Column]
2410
1816
  def columns
2411
- sheet if @current_sheet.nil?
1817
+ ensure_sheet_started!
2412
1818
  @current_columns.map do |c|
2413
1819
  if c.is_a?(Elements::Column)
2414
1820
  c
2415
1821
  else
2416
1822
  idx = c[:index]
2417
1823
  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]
1824
+ unmapped = c.except(:index, :width, :hidden, :custom_width, :outline_level, :style, :style_index, :collapsed, :best_fit)
2421
1825
  Elements::Column.new(
2422
1826
  index: idx,
2423
1827
  width: c[:width],
@@ -2425,6 +1829,8 @@ module Xlsxrb
2425
1829
  custom_width: c[:custom_width] ? true : false,
2426
1830
  outline_level: c[:outline_level],
2427
1831
  style_index: style_idx,
1832
+ collapsed: c[:collapsed] ? true : false,
1833
+ best_fit: c[:best_fit] ? true : false,
2428
1834
  unmapped_data: unmapped
2429
1835
  )
2430
1836
  end
@@ -2451,12 +1857,6 @@ module Xlsxrb
2451
1857
  def group_columns(index, level: 1, collapsed: false, hidden: false, width: nil, style: nil)
2452
1858
  column(index, outline_level: level, collapsed: collapsed, hidden: hidden, width: width, style: style)
2453
1859
  end
2454
- # @deprecated Use {#group_columns} instead. Will be removed in 0.2.0.
2455
- alias group_column group_columns
2456
- # @deprecated Use {#group_columns} instead. Will be removed in 0.2.0.
2457
- alias group_cols group_columns
2458
- # @deprecated Use {#group_columns} instead. Will be removed in 0.2.0.
2459
- alias group_col group_columns
2460
1860
 
2461
1861
  # Groups multiple rows with outline hierarchy with a block.
2462
1862
  #
@@ -2492,10 +1892,11 @@ module Xlsxrb
2492
1892
  @current_row_hidden = prev_hidden
2493
1893
  end
2494
1894
  end
2495
- # @deprecated Use {#group_rows} instead. Will be removed in 0.2.0.
2496
- alias group_row group_rows
2497
1895
 
2498
- # Configures worksheet-level outline and grouping view properties.
1896
+ # Configures or queries worksheet-level outline and grouping view properties.
1897
+ #
1898
+ # When called with no arguments, returns the outline properties Hash.
1899
+ # When called with arguments, updates outline properties and returns nil.
2499
1900
  #
2500
1901
  # @example Show summary row below detail rows
2501
1902
  # sheet.outline_properties(summary_below: true, summary_right: true)
@@ -2503,22 +1904,21 @@ module Xlsxrb
2503
1904
  # @param summary_below [Boolean, nil] Flag indicating if summary rows appear below detail rows.
2504
1905
  # @param summary_right [Boolean, nil] Flag indicating if summary columns appear to the right of detail columns.
2505
1906
  # @param show_outline_symbols [Boolean, nil] Flag indicating whether outline symbols are visible.
2506
- # @param show_symbols [Boolean, nil] Deprecated alias for show_outline_symbols.
2507
1907
  # @param apply_styles [Boolean, nil] Flag indicating whether automatic styles apply to outlines.
2508
1908
  # @param opts [Hash] Additional options.
2509
1909
  # @return [Hash<Symbol, untyped>, void]
2510
1910
  # @api public
2511
- #: (?summary_below: bool?, ?summary_right: bool?, ?show_outline_symbols: bool?, ?show_symbols: bool?, ?apply_styles: bool?, **untyped opts) -> (Hash[Symbol, untyped] | void)
2512
- def outline_properties(summary_below: nil, summary_right: nil, show_outline_symbols: nil, show_symbols: nil, apply_styles: nil, **opts)
1911
+ #: () -> Hash[Symbol, untyped]
1912
+ #: (?summary_below: bool?, ?summary_right: bool?, ?show_outline_symbols: bool?, ?apply_styles: bool?, **untyped opts) -> void
1913
+ def outline_properties(summary_below: nil, summary_right: nil, show_outline_symbols: nil, apply_styles: nil, **opts)
2513
1914
  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?
2515
1915
 
2516
- warn "[Xlsxrb DEPRECATION] outline_properties keyword show_symbols: is deprecated; use show_outline_symbols: instead.", uplevel: 1 unless show_symbols.nil?
1916
+ 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? && apply_styles.nil? && opts.empty?
1917
+
2517
1918
  props = (@current_sheet_properties[:outline_properties] || {}).dup
2518
1919
  props[:summary_below] = summary_below unless summary_below.nil?
2519
1920
  props[:summary_right] = summary_right unless summary_right.nil?
2520
- symbols = show_outline_symbols.nil? ? show_symbols : show_outline_symbols
2521
- props[:show_outline_symbols] = symbols unless symbols.nil?
1921
+ props[:show_outline_symbols] = show_outline_symbols unless show_outline_symbols.nil?
2522
1922
  props[:apply_styles] = apply_styles unless apply_styles.nil?
2523
1923
  props.merge!(opts)
2524
1924
  @current_sheet_properties[:outline_properties] = props
@@ -2526,8 +1926,6 @@ module Xlsxrb
2526
1926
  @current_sheet_properties[:summary_right] = props[:summary_right] unless props[:summary_right].nil?
2527
1927
  nil
2528
1928
  end
2529
- # @deprecated Use {#outline_properties} instead. Will be removed in 0.2.0.
2530
- alias outline_pr outline_properties
2531
1929
 
2532
1930
  # Sets worksheet outline and grouping view properties.
2533
1931
  #
@@ -2536,11 +1934,11 @@ module Xlsxrb
2536
1934
  # @api public
2537
1935
  #: (Hash[Symbol, untyped] opts) -> void
2538
1936
  def outline_properties=(opts)
1937
+ sheet if @current_sheet.nil?
2539
1938
  h = opts.respond_to?(:to_h) ? opts.to_h : (opts || {})
2540
1939
  outline_properties(**h)
2541
1940
  nil
2542
1941
  end
2543
- alias outline_pr= outline_properties=
2544
1942
 
2545
1943
  # Adds a chart to the current worksheet.
2546
1944
  #
@@ -2557,7 +1955,7 @@ module Xlsxrb
2557
1955
  options = options.merge(type: type) if type
2558
1956
  if block_given?
2559
1957
  builder = ChartBuilder.new
2560
- builder.type(type) if type
1958
+ builder.type = type if type
2561
1959
  yield builder
2562
1960
  options = builder.options.merge(options)
2563
1961
  end
@@ -2595,16 +1993,14 @@ module Xlsxrb
2595
1993
  @current_hyperlinks << link
2596
1994
  end
2597
1995
 
2598
- # Sets the auto-filter range on the active sheet.
1996
+ # Returns the auto-filter range on the active sheet, or nil if none.
2599
1997
  #
2600
- # @param range [String, nil] Cell range (e.g. "A1:E100").
2601
- # @return [void]
1998
+ # @return [String, nil]
2602
1999
  # @api public
2603
- #: (String? range) -> void
2604
- def auto_filter(range)
2605
- sheet if @current_sheet.nil?
2606
- @current_auto_filter = range
2607
- nil
2000
+ #: () -> String?
2001
+ def auto_filter
2002
+ ensure_sheet_started!
2003
+ @current_auto_filter
2608
2004
  end
2609
2005
 
2610
2006
  # Sets the auto-filter range for the current worksheet.
@@ -2614,8 +2010,8 @@ module Xlsxrb
2614
2010
  # @api public
2615
2011
  #: (String? range) -> String?
2616
2012
  def auto_filter=(range)
2617
- auto_filter(range)
2618
- range
2013
+ ensure_sheet_started!
2014
+ @current_auto_filter = range&.to_s
2619
2015
  end
2620
2016
 
2621
2017
  # Sets filter criteria on a column in the auto-filter.
@@ -2630,7 +2026,7 @@ module Xlsxrb
2630
2026
  # @param filter [Hash] Filter definition.
2631
2027
  # @return [void]
2632
2028
  # @api public
2633
- #: (Integer | String | Symbol col_id, Hash[untyped, untyped] filter) -> void
2029
+ #: (Integer | String | Symbol col_id, (Hash[untyped, untyped] | Array[untyped]) filter) -> void
2634
2030
  def filter_column(col_id, filter)
2635
2031
  sheet if @current_sheet.nil?
2636
2032
  col_id = Elements::Cell._column_index(col_id) if col_id.is_a?(String) || col_id.is_a?(Symbol)
@@ -2638,33 +2034,38 @@ module Xlsxrb
2638
2034
  nil
2639
2035
  end
2640
2036
 
2641
- # Configures column sort state on the active sheet.
2037
+ # Configures or queries column sort state on the active sheet.
2642
2038
  #
2643
- # @param ref [String] The sorted range.
2644
- # @param sort_conditions [Array<Hash>] Sort conditions.
2039
+ # When called with no arguments, returns the {Elements::SortState} value object.
2040
+ # When called with arguments, updates sort state and returns nil.
2041
+ #
2042
+ # @param ref [String, nil] The sorted range.
2043
+ # @param sort_conditions [Array<Hash>, nil] Sort conditions.
2044
+ # @param case_sensitive [Boolean] Whether sorting is case sensitive.
2045
+ # @param sort_method [String, nil] Sort method.
2645
2046
  # @param opts [Hash] Additional options.
2646
- # @return [Elements::SortState, Hash<Symbol, untyped>, nil, void]
2047
+ # @return [Elements::SortState, nil, void]
2647
2048
  # @api public
2648
- #: (?String? ref, ?Array[Hash[untyped, untyped]]? sort_conditions, **untyped opts) -> (untyped | void)
2649
- def sort_state(ref = nil, sort_conditions = nil, **opts)
2049
+ #: () -> Elements::SortState?
2050
+ #: (?String? ref, ?Array[Hash[untyped, untyped]]? sort_conditions, ?case_sensitive: bool, ?sort_method: String?, **untyped opts) -> void
2051
+ def sort_state(ref = nil, sort_conditions = nil, case_sensitive: false, sort_method: nil, **opts)
2650
2052
  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
2053
+ if ref.nil? && sort_conditions.nil?
2054
+ return @current_sort_state ? Elements::SortState.new(**@current_sort_state) : nil
2656
2055
  end
2657
2056
 
2658
- @current_sort_state = { ref: ref, sort_conditions: sort_conditions }.merge(opts)
2057
+ entry = { ref: ref, sort_conditions: sort_conditions, case_sensitive: case_sensitive }
2058
+ entry[:sort_method] = sort_method if sort_method
2059
+ @current_sort_state = entry.merge(opts)
2659
2060
  nil
2660
2061
  end
2661
2062
 
2662
- # Sets column sort state for the sheet.
2063
+ # Sets column sort state on the active sheet.
2663
2064
  #
2664
2065
  # @param opts [Elements::SortState, Hash, nil] Sort state options.
2665
2066
  # @return [void]
2666
2067
  # @api public
2667
- #: (untyped opts) -> void
2068
+ #: (Elements::SortState | Hash[Symbol, untyped] | nil opts) -> void
2668
2069
  def sort_state=(opts)
2669
2070
  sheet if @current_sheet.nil?
2670
2071
  @current_sort_state = opts&.respond_to?(:to_h) ? opts.to_h : opts
@@ -2685,13 +2086,6 @@ module Xlsxrb
2685
2086
  @current_data_validations.concat(normalized_list)
2686
2087
  end
2687
2088
 
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
-
2695
2089
  # Adds a conditional formatting rule.
2696
2090
  # Supports block configuration via {ConditionalFormatBuilder} and coordinate targeting (:columns, :rows).
2697
2091
  #
@@ -2745,29 +2139,24 @@ module Xlsxrb
2745
2139
  # @param source_ref [String] Source data range.
2746
2140
  # @param row_fields [Array<Integer>] 0-based field indices for rows.
2747
2141
  # @param data_fields [Array<Hash>] Data fields.
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.
2142
+ # @param column_fields [Array<Integer>, nil] 0-based field indices for columns.
2143
+ # @param ref [String, nil] Top-left destination cell (default: "E1").
2752
2144
  # @param name [String, nil] Pivot table name.
2753
2145
  # @param field_names [Array<String>, nil] Override field names.
2754
- # @param items [Array, nil] Items configuration.
2146
+ # @param items [Hash{Integer => Array}, nil] Items of each field, by 0-based field index.
2755
2147
  # @param opts [Hash] Additional options.
2756
2148
  # @return [void]
2757
2149
  # @api public
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)
2150
+ #: (untyped source_ref, row_fields: untyped, data_fields: untyped, ?column_fields: untyped, ?ref: untyped, ?name: untyped, ?field_names: untyped, ?items: untyped, **untyped opts) -> void
2151
+ def pivot_table(source_ref, row_fields:, data_fields:, column_fields: nil, ref: nil, name: nil, field_names: nil, items: nil, **opts)
2760
2152
  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"
2153
+ c_fields = column_fields || []
2154
+ target_ref = ref || "E1"
2765
2155
  @current_pivot_tables ||= []
2766
2156
  entry = {
2767
2157
  source_ref: source_ref, row_fields: row_fields,
2768
2158
  data_fields: data_fields, column_fields: c_fields,
2769
- col_fields: c_fields, ref: target_ref,
2770
- dest_ref: target_ref, name: name,
2159
+ ref: target_ref, destination: target_ref, name: name,
2771
2160
  field_names: field_names, items: items
2772
2161
  }.merge(opts)
2773
2162
  @current_pivot_tables << entry
@@ -2778,13 +2167,14 @@ module Xlsxrb
2778
2167
  # @param cell [String, Integer] Cell coordinate (e.g. "A1").
2779
2168
  # @param text [String] Comment text.
2780
2169
  # @param author [String] Author name.
2170
+ # @param visible [Boolean] Whether the comment is always shown instead of on hover.
2781
2171
  # @return [void]
2782
2172
  # @api public
2783
- #: (String | Integer cell, String text, ?author: ::String) -> void
2784
- def comment(cell, text, author: "Author")
2173
+ #: (String | Integer cell, String text, ?author: ::String, ?visible: bool) -> void
2174
+ def comment(cell, text, author: "Author", visible: false)
2785
2175
  sheet if @current_sheet.nil?
2786
2176
  ref_str = cell.to_s
2787
- @current_comments << { ref: ref_str, text: text, author: author }
2177
+ @current_comments << { ref: ref_str, text: text, author: author, visible: visible }
2788
2178
  nil
2789
2179
  end
2790
2180
 
@@ -2793,7 +2183,7 @@ module Xlsxrb
2793
2183
  # @param cell [String, Integer] Cell coordinate (e.g. "A1").
2794
2184
  # @param text [String] Comment text.
2795
2185
  # @param author [String] Author name.
2796
- # @param timestamp [String, Time, nil] Optional ISO 8601 timestamp.
2186
+ # @param visible [Boolean] Whether the comment is always shown instead of on hover. # @param timestamp [String, Time, nil] Optional ISO 8601 timestamp.
2797
2187
  # @param id [String, nil] Optional GUID for this comment.
2798
2188
  # @param parent_id [String, nil] Optional parent comment GUID for replies.
2799
2189
  # @param done [Boolean, nil] Optional resolved flag.
@@ -2810,16 +2200,17 @@ module Xlsxrb
2810
2200
  text: text,
2811
2201
  author: author,
2812
2202
  timestamp: timestamp,
2203
+ created_at: timestamp,
2813
2204
  id: id,
2814
2205
  parent_id: parent_id,
2815
2206
  done: done ? true : false,
2207
+ resolved: done ? true : false,
2816
2208
  user_id: user_id,
2209
+ author_id: user_id,
2817
2210
  provider_id: provider_id
2818
2211
  }.compact
2819
2212
  nil
2820
2213
  end
2821
- # @deprecated Use {#threaded_comment} instead. Will be removed in 0.2.0.
2822
- alias add_threaded_comment threaded_comment
2823
2214
 
2824
2215
  # Adds a sparkline group.
2825
2216
  #
@@ -2837,86 +2228,45 @@ module Xlsxrb
2837
2228
  @current_sparkline_groups << group
2838
2229
  end
2839
2230
 
2840
- # Adds a single sparkline to the sheet.
2841
- #
2842
- # @example Add a line sparkline
2843
- # writer.add_sparkline(location: "F1", range: "A1:E1")
2844
- #
2845
- # @example Add a column sparkline with high/low markers
2846
- # writer.add_sparkline(location: "F2", range: "A2:E2", type: :column, high: true, low: true)
2847
- #
2848
- # @example Add a win/loss sparkline
2849
- # writer.add_sparkline(location: "F3", range: "A3:E3", type: :win_loss)
2850
- #
2851
- # @param location [String, nil] Target cell for the sparkline (e.g. "F1").
2852
- # @param range [String, nil] Data range for the sparkline (e.g. "A1:E1").
2853
- # @param type [Symbol, String, nil] Sparkline type (:line, :column, :win_loss / :stacked).
2854
- # @param opts [Hash] Additional sparkline options.
2855
- # @deprecated Use {#sparkline_group} instead. Will be removed in 0.2.0.
2856
- # @return [void]
2857
- # @api public
2858
- #: (?location: String?, ?range: String?, ?type: (String | Symbol)?, **untyped opts) -> void
2859
- def add_sparkline(location: nil, range: nil, type: nil, **opts)
2860
- warn "[DEPRECATION] #add_sparkline is deprecated; use #sparkline_group instead.", uplevel: 1
2861
- loc = location || opts.delete(:location_ref)
2862
- rng = range || opts.delete(:data_ref) || opts.delete(:data)
2863
- raise ArgumentError, "Missing required location: parameter for sparkline" unless loc
2864
- raise ArgumentError, "Missing required range: parameter for sparkline" unless rng
2865
-
2866
- mapped_type = case type&.to_s
2867
- when "win_loss" then "stacked"
2868
- when nil, "" then nil
2869
- else type.to_s
2870
- end
2871
- sparkline_group(sparklines: [{ data_ref: rng.to_s, location_ref: loc.to_s }], type: mapped_type, **opts)
2872
- end
2873
-
2874
2231
  # Merges a range of cells into a single cell.
2875
2232
  #
2876
2233
  # @example
2877
2234
  # sheet.merge("A1:C1")
2878
2235
  #
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.
2880
- # @param range [String, Hash, nil] Cell range (e.g. "A1:B2") or hash of coordinates.
2881
- # @param row [Integer, nil] Single row index.
2882
- # @param col_start [Integer, String, nil] Starting column.
2883
- # @param col_end [Integer, String, nil] Ending column.
2884
- # @param row_start [Integer, nil] Starting row index.
2885
- # @param row_end [Integer, nil] Ending row index.
2236
+ # @param range [String] Cell range (e.g. "A1:B2").
2886
2237
  # @return [void]
2887
2238
  # @api public
2888
- #: (?(String | Hash[Symbol, Integer | String])? range, ?row: Integer?, ?col_start: (Integer | String)?, ?col_end: (Integer | String)?, ?row_start: Integer?, ?row_end: Integer?) -> void
2889
- def merge(range = nil, row: nil, col_start: nil, col_end: nil, row_start: nil, row_end: nil)
2239
+ #: (String range) -> void
2240
+ def merge(range)
2890
2241
  sheet if @current_sheet.nil?
2891
- canonical = DslHelpers.normalize_merge_range(
2892
- range,
2893
- row: row, col_start: col_start, col_end: col_end,
2894
- row_start: row_start, row_end: row_end,
2895
- strict_excel_mode: @strict_excel_mode
2896
- )
2242
+ canonical = DslHelpers.normalize_merge_range(range, strict_excel_mode: @strict_excel_mode)
2897
2243
  @current_merge_cells << canonical unless @current_merge_cells.include?(canonical)
2898
2244
  end
2899
2245
 
2900
- # Freezes window panes at the given row and column, or queries freeze pane settings.
2246
+ # Configures or queries freeze panes (<pane state="frozen">).
2247
+ #
2248
+ # When called with no arguments, returns the {Elements::FreezePane} value object or nil.
2249
+ # When called with arguments, configures the freeze pane and returns nil.
2901
2250
  #
2902
2251
  # @param row [Integer, nil] Number of rows to freeze.
2903
2252
  # @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]
2253
+ # @param top_left_cell [String, nil] Top-left cell reference in bottom-right pane.
2254
+ # @param active_pane [String, Symbol, nil] Active pane identifier.
2255
+ # @return [Elements::FreezePane, nil, void]
2906
2256
  # @api public
2907
- #: (?row: Integer | nil, ?column: (Integer | String)?, ?col: (Integer | String)?) -> (untyped | void)
2908
- def freeze_pane(row: nil, column: nil, col: nil)
2257
+ #: () -> Elements::FreezePane?
2258
+ #: (?row: Integer | nil, ?column: (Integer | String)?, ?top_left_cell: String?, ?active_pane: (String | Symbol)?) -> void
2259
+ def freeze_pane(row: nil, column: nil, top_left_cell: nil, active_pane: nil)
2909
2260
  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
2261
+ if row.nil? && column.nil? && top_left_cell.nil? && active_pane.nil?
2262
+ return @current_freeze_pane ? Elements::FreezePane.new(**@current_freeze_pane) : nil
2915
2263
  end
2916
2264
 
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 }
2265
+ col_val = column ? Elements::Cell._column_index(column) : 0
2266
+ entry = { row: row || 0, column: col_val }
2267
+ entry[:top_left_cell] = top_left_cell if top_left_cell
2268
+ entry[:active_pane] = active_pane.to_s if active_pane
2269
+ @current_freeze_pane = entry
2920
2270
  nil
2921
2271
  end
2922
2272
 
@@ -2925,7 +2275,7 @@ module Xlsxrb
2925
2275
  # @param opts [Elements::FreezePane, Hash, nil] Freeze pane options.
2926
2276
  # @return [void]
2927
2277
  # @api public
2928
- #: (untyped opts) -> void
2278
+ #: (Elements::FreezePane | Hash[Symbol, untyped] | nil opts) -> void
2929
2279
  def freeze_pane=(opts)
2930
2280
  sheet if @current_sheet.nil?
2931
2281
  if opts.nil?
@@ -2934,33 +2284,36 @@ module Xlsxrb
2934
2284
  h = opts.respond_to?(:to_h) ? opts.to_h : opts
2935
2285
  c = h[:column] || h[:col]
2936
2286
  c = Elements::Cell._column_index(c) if c
2937
- @current_freeze_pane = { row: h[:row] || 0, col: c || 0, column: c || 0 }
2287
+ entry = { row: h[:row] || 0, column: c || 0 }
2288
+ entry[:top_left_cell] = h[:top_left_cell] if h[:top_left_cell]
2289
+ entry[:active_pane] = h[:active_pane].to_s if h[:active_pane]
2290
+ @current_freeze_pane = entry
2938
2291
  end
2939
2292
  nil
2940
2293
  end
2941
2294
 
2942
- # Splits window panes without freezing or queries split pane settings.
2295
+ # Splits window panes without freezing or queries split pane settings (<pane>).
2296
+ #
2297
+ # When called with no arguments, returns the {Elements::SplitPane} value object or nil.
2298
+ # When called with arguments, configures the split pane and returns nil.
2943
2299
  #
2944
2300
  # @param x_split [Integer, nil] Horizontal split in points.
2945
2301
  # @param y_split [Integer, nil] Vertical split in points.
2946
2302
  # @param top_left_cell [String, nil] Top-left cell reference in bottom-right pane.
2947
2303
  # @param active_pane [String, Symbol, nil] Active pane identifier.
2948
2304
  # @param state [String, Symbol, nil] Split state.
2949
- # @return [Elements::SplitPane, Hash<Symbol, untyped>, nil, void]
2305
+ # @return [Elements::SplitPane, nil, void]
2950
2306
  # @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)
2307
+ #: () -> Elements::SplitPane?
2308
+ #: (?x_split: Integer | nil, ?y_split: Integer | nil, ?top_left_cell: String?, ?active_pane: (String | Symbol)?) -> void
2309
+ def split_pane(x_split: nil, y_split: nil, top_left_cell: nil, active_pane: nil)
2953
2310
  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
2311
+ if x_split.nil? && y_split.nil? && top_left_cell.nil? && active_pane.nil?
2312
+ return @current_split_pane ? Elements::SplitPane.new(**@current_split_pane) : nil
2959
2313
  end
2960
2314
 
2961
2315
  entry = { x_split: x_split || 0, y_split: y_split || 0, top_left_cell: top_left_cell }
2962
2316
  entry[:active_pane] = active_pane.to_s if active_pane
2963
- entry[:state] = state.to_s if state
2964
2317
  @current_split_pane = entry
2965
2318
  nil
2966
2319
  end
@@ -2970,7 +2323,7 @@ module Xlsxrb
2970
2323
  # @param opts [Elements::SplitPane, Hash, nil] Split pane options.
2971
2324
  # @return [void]
2972
2325
  # @api public
2973
- #: (untyped opts) -> void
2326
+ #: (Elements::SplitPane | Hash[Symbol, untyped] | nil opts) -> void
2974
2327
  def split_pane=(opts)
2975
2328
  sheet if @current_sheet.nil?
2976
2329
  if opts.nil?
@@ -2979,32 +2332,30 @@ module Xlsxrb
2979
2332
  h = opts.respond_to?(:to_h) ? opts.to_h : opts
2980
2333
  entry = { x_split: h[:x_split] || 0, y_split: h[:y_split] || 0, top_left_cell: h[:top_left_cell] }
2981
2334
  entry[:active_pane] = h[:active_pane].to_s if h[:active_pane]
2982
- entry[:state] = h[:state].to_s if h[:state]
2983
2335
  @current_split_pane = entry
2984
2336
  end
2985
2337
  nil
2986
2338
  end
2987
2339
 
2988
- # Sets or queries the active cell selection on the current sheet.
2340
+ # Sets or queries the active cell selection on the current sheet (<selection>).
2341
+ #
2342
+ # When called with no arguments, returns the selection ({Elements::Selection}, Array, or nil).
2343
+ # When called with arguments, updates the selection and returns nil.
2989
2344
  #
2990
2345
  # @param active_cell [String, nil] Active cell reference (e.g. "A1") or range (e.g. "A1:D10").
2991
2346
  # @param sqref [String, nil] Selection range.
2992
2347
  # @param pane [String, Symbol, nil] Target pane.
2993
- # @return [Elements::Selection, Array<Elements::Selection>, Hash<Symbol, untyped>, nil, void]
2348
+ # @return [Elements::Selection, Array<Elements::Selection>, nil, void]
2994
2349
  # @api public
2995
- #: (?String? active_cell, ?sqref: String?, ?pane: (String | Symbol)?) -> (untyped | void)
2350
+ #: () -> (Elements::Selection | Array[Elements::Selection])?
2351
+ #: (?String? active_cell, ?sqref: String?, ?pane: (String | Symbol)?) -> void
2996
2352
  def selection(active_cell = nil, sqref: nil, pane: nil)
2997
2353
  sheet if @current_sheet.nil?
2998
2354
  if active_cell.nil? && sqref.nil? && pane.nil?
2999
2355
  return nil if @current_selection.nil?
2356
+ return @current_selection.map { |s| Elements::Selection.new(**s) } if @current_selection.is_a?(Array)
3000
2357
 
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
2358
+ return Elements::Selection.new(**@current_selection)
3008
2359
  end
3009
2360
 
3010
2361
  if sqref.nil? && active_cell.is_a?(String) && active_cell.include?(":")
@@ -3013,8 +2364,9 @@ module Xlsxrb
3013
2364
  else
3014
2365
  sqref ||= active_cell
3015
2366
  end
3016
- @current_selection = { active_cell: active_cell, sqref: sqref }
3017
- @current_selection[:pane] = pane if pane
2367
+ sel = { active_cell: active_cell, sqref: sqref }
2368
+ sel[:pane] = pane if pane
2369
+ @current_selection = sel
3018
2370
  nil
3019
2371
  end
3020
2372
 
@@ -3023,7 +2375,7 @@ module Xlsxrb
3023
2375
  # @param opts [Elements::Selection, Array<Elements::Selection, Hash>, Hash, nil]
3024
2376
  # @return [void]
3025
2377
  # @api public
3026
- #: (untyped opts) -> void
2378
+ #: (Elements::Selection | Array[Elements::Selection | Hash[Symbol, untyped]] | Hash[Symbol, untyped] | nil opts) -> void
3027
2379
  def selection=(opts)
3028
2380
  sheet if @current_sheet.nil?
3029
2381
  @current_selection = if opts.nil?
@@ -3036,16 +2388,9 @@ module Xlsxrb
3036
2388
  nil
3037
2389
  end
3038
2390
 
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>).
2391
+ # Configures or queries page margins in inches for printing (<pageMargins>).
3047
2392
  #
3048
- # When called with no arguments, returns the page margins value object or hash.
2393
+ # When called with no arguments, returns the {Elements::PageMargins} value object or nil.
3049
2394
  # When called with arguments, configures page margins and returns nil.
3050
2395
  #
3051
2396
  # @param left [Float, nil] Left margin.
@@ -3054,16 +2399,14 @@ module Xlsxrb
3054
2399
  # @param bottom [Float, nil] Bottom margin.
3055
2400
  # @param header [Float, nil] Header margin.
3056
2401
  # @param footer [Float, nil] Footer margin.
3057
- # @return [Elements::PageMargins, Hash<Symbol, untyped>, nil, void]
2402
+ # @return [Elements::PageMargins, nil, void]
3058
2403
  # @api public
3059
- #: (?left: Float?, ?right: Float?, ?top: Float?, ?bottom: Float?, ?header: Float?, ?footer: Float?) -> (untyped | void)
2404
+ #: () -> Elements::PageMargins?
2405
+ #: (?left: Float?, ?right: Float?, ?top: Float?, ?bottom: Float?, ?header: Float?, ?footer: Float?) -> void
3060
2406
  def page_margins(left: nil, right: nil, top: nil, bottom: nil, header: nil, footer: nil)
3061
2407
  sheet if @current_sheet.nil?
3062
2408
  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
2409
+ return @current_page_margins ? Elements::PageMargins.new(**@current_page_margins) : nil
3067
2410
  end
3068
2411
 
3069
2412
  @current_page_margins = DslHelpers.normalize_page_margins(
@@ -3077,7 +2420,7 @@ module Xlsxrb
3077
2420
  # @param opts [Hash, Elements::PageMargins, nil]
3078
2421
  # @return [void]
3079
2422
  # @api public
3080
- #: (untyped opts) -> void
2423
+ #: (Hash[Symbol, untyped] | Elements::PageMargins | nil opts) -> void
3081
2424
  def page_margins=(opts)
3082
2425
  sheet if @current_sheet.nil?
3083
2426
  if opts.nil?
@@ -3091,18 +2434,17 @@ module Xlsxrb
3091
2434
 
3092
2435
  # Configures or queries page setup configuration (<pageSetup>).
3093
2436
  #
3094
- # When called with no arguments, returns the page setup value object or hash.
2437
+ # When called with no arguments, returns the {Elements::PageSetup} value object.
3095
2438
  # When called with keyword arguments, updates page setup and returns nil.
3096
2439
  #
3097
2440
  # @param opts [Hash] Page setup options (e.g. orientation: :landscape).
3098
- # @return [Elements::PageSetup, Hash<Symbol, untyped>, void]
2441
+ # @return [Elements::PageSetup, void]
3099
2442
  # @api public
3100
- #: (**untyped opts) -> (untyped | void)
2443
+ #: () -> Elements::PageSetup
2444
+ #: (**untyped opts) -> void
3101
2445
  def page_setup(**opts)
3102
2446
  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
2447
+ return Elements::PageSetup.new(**@current_page_setup) if opts.empty?
3106
2448
 
3107
2449
  @current_page_setup.merge!(opts)
3108
2450
  @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)
@@ -3114,7 +2456,7 @@ module Xlsxrb
3114
2456
  # @param opts [Hash, Elements::PageSetup]
3115
2457
  # @return [void]
3116
2458
  # @api public
3117
- #: (untyped opts) -> void
2459
+ #: (Hash[Symbol, untyped] | Elements::PageSetup opts) -> void
3118
2460
  def page_setup=(opts)
3119
2461
  sheet if @current_sheet.nil?
3120
2462
  h = opts.respond_to?(:to_h) ? opts.to_h : (opts || {})
@@ -3124,18 +2466,17 @@ module Xlsxrb
3124
2466
 
3125
2467
  # Configures or queries headers and footers for printing (<headerFooter>).
3126
2468
  #
3127
- # When called with no arguments, returns the header/footer value object or hash.
2469
+ # When called with no arguments, returns the {Elements::HeaderFooter} value object.
3128
2470
  # When called with keyword arguments, updates headers and footers and returns nil.
3129
2471
  #
3130
2472
  # @param opts [Hash] Header/footer options.
3131
- # @return [Elements::HeaderFooter, Hash<Symbol, untyped>, void]
2473
+ # @return [Elements::HeaderFooter, void]
3132
2474
  # @api public
3133
- #: (**untyped opts) -> (untyped | void)
2475
+ #: () -> Elements::HeaderFooter
2476
+ #: (**untyped opts) -> void
3134
2477
  def header_footer(**opts)
3135
2478
  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
2479
+ return Elements::HeaderFooter.new(**@current_header_footer) if opts.empty?
3139
2480
 
3140
2481
  @current_header_footer.merge!(opts)
3141
2482
  nil
@@ -3146,7 +2487,7 @@ module Xlsxrb
3146
2487
  # @param opts [Hash, Elements::HeaderFooter]
3147
2488
  # @return [void]
3148
2489
  # @api public
3149
- #: (untyped opts) -> void
2490
+ #: (Hash[Symbol, untyped] | Elements::HeaderFooter opts) -> void
3150
2491
  def header_footer=(opts)
3151
2492
  sheet if @current_sheet.nil?
3152
2493
  h = opts.respond_to?(:to_h) ? opts.to_h : (opts || {})
@@ -3157,23 +2498,17 @@ module Xlsxrb
3157
2498
  # Configures or queries print options (<printOptions>).
3158
2499
  #
3159
2500
  # 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.
2501
+ # When called with keyword options, configures print options and returns nil.
3161
2502
  #
3162
- # @param name [Symbol, String, Hash, Elements::MetadataRecord, nil] Option name or hash/record of options.
3163
- # @param value [Object, nil] Option value.
3164
2503
  # @param opts [Hash] Additional print options.
3165
2504
  # @return [Elements::PrintOptions, void]
3166
2505
  # @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)
2506
+ #: () -> Elements::PrintOptions
2507
+ #: (**untyped opts) -> void
2508
+ def print_options(**opts)
3169
2509
  sheet if @current_sheet.nil?
3170
- return Elements::PrintOptions.new(**@current_print_options) if name.nil? && value.nil? && opts.empty?
2510
+ return Elements::PrintOptions.new(**@current_print_options) if opts.empty?
3171
2511
 
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
2512
  opts.each { |k, v| @current_print_options[k.to_sym] = v }
3178
2513
  nil
3179
2514
  end
@@ -3191,22 +2526,20 @@ module Xlsxrb
3191
2526
  nil
3192
2527
  end
3193
2528
 
3194
- # Configures or queries sheet-level protection with optional password hashing (<sheetProtection>).
2529
+ # Sets or queries sheet-level protection with optional password hashing (<sheetProtection>).
3195
2530
  #
3196
- # When called with no arguments, returns the sheet protection value object or hash.
2531
+ # When called with no arguments, returns the {Elements::SheetProtection} value object or nil.
3197
2532
  # When called with keyword arguments, sets sheet protection and returns nil.
3198
2533
  #
3199
2534
  # @param opts [Hash] Protection options.
3200
- # @return [Elements::SheetProtection, Hash<Symbol, untyped>, nil, void]
2535
+ # @return [Elements::SheetProtection, nil, void]
3201
2536
  # @api public
3202
- #: (**untyped opts) -> (untyped | void)
2537
+ #: () -> Elements::SheetProtection?
2538
+ #: (**untyped opts) -> void
3203
2539
  def sheet_protection(**opts)
3204
2540
  sheet if @current_sheet.nil?
3205
2541
  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
2542
+ @current_sheet_protection ? Elements::SheetProtection.new(**@current_sheet_protection) : nil
3210
2543
  else
3211
2544
  @current_sheet_protection = DslHelpers.normalize_protection_options(opts)
3212
2545
  nil
@@ -3218,7 +2551,7 @@ module Xlsxrb
3218
2551
  # @param opts [Elements::SheetProtection, Hash, Boolean, nil]
3219
2552
  # @return [void]
3220
2553
  # @api public
3221
- #: (untyped opts) -> void
2554
+ #: (Elements::SheetProtection | Hash[Symbol, untyped] | bool | nil opts) -> void
3222
2555
  def sheet_protection=(opts)
3223
2556
  sheet if @current_sheet.nil?
3224
2557
  if opts.nil? || opts == false
@@ -3232,63 +2565,53 @@ module Xlsxrb
3232
2565
  nil
3233
2566
  end
3234
2567
 
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(...)
3240
- end
3241
-
3242
2568
  # Inserts an embedded image into the active sheet.
3243
2569
  #
3244
2570
  # @param file_data [String] Binary image data.
3245
2571
  # @param ext [String] File extension ("png", "jpeg", etc.).
3246
2572
  # @param from_column [Integer, nil] Top-left starting column.
3247
- # @param from_col [Integer, nil] Deprecated alias for from_column.
3248
2573
  # @param from_row [Integer] Top-left starting row.
3249
2574
  # @param to_column [Integer, nil] Bottom-right ending column.
3250
- # @param to_col [Integer, nil] Deprecated alias for to_column.
3251
2575
  # @param to_row [Integer] Bottom-right ending row.
3252
2576
  # @param opts [Hash] Additional options.
3253
2577
  # @return [void]
3254
2578
  # @api public
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
2579
+ #: (String file_data, ?ext: ::String, ?from_column: ::Integer?, ?from_row: ::Integer, ?to_column: ::Integer?, ?to_row: ::Integer, **untyped opts) -> void
2580
+ def image(file_data, ext: "png", from_column: nil, from_row: 0, to_column: nil, to_row: 10, **opts)
2581
+ fc = from_column || 0
2582
+ tc = to_column || 5
3261
2583
  sheet if @current_sheet.nil?
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 }
2584
+ img = { file_data: file_data, ext: ext, from_column: fc, from_row: from_row, to_column: tc, to_row: to_row }
3263
2585
  img.merge!(opts)
3264
2586
  @current_images << img
3265
2587
  end
3266
2588
 
3267
- # Configures the worksheet background image (<picture>).
3268
- #
3269
- # @example Set background image from binary data
3270
- # sheet.background_image(png_bytes, ext: "png")
2589
+ # Worksheet background image (<picture>).
3271
2590
  #
3272
- # @example Set background image from file path
3273
- # sheet.background_image("path/to/background.png")
3274
- #
3275
- # @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#background_image=} instead.
3276
- # @param file_data [String, Hash, Elements::Image, nil] Image binary data, file path, or image options hash.
3277
- # @param ext [String, nil] Image extension ("png", "jpeg", "jpg", "gif", etc.).
3278
- # @param opts [Hash] Additional image options.
3279
- # @return [Hash, nil]
2591
+ # @return [Elements::BackgroundImage, nil]
3280
2592
  # @api public
3281
- #: (?untyped file_data, ?ext: ::String?, **untyped opts) -> Hash[Symbol, untyped]?
3282
- def background_image(file_data = nil, ext: nil, **opts)
3283
- if file_data.nil? && ext.nil? && opts.empty?
3284
- return nil unless @current_background_image
2593
+ #: () -> Elements::BackgroundImage?
2594
+ def background_image
2595
+ sheet if @current_sheet.nil?
2596
+ return nil unless @current_background_image
3285
2597
 
3286
- return @current_background_image.is_a?(Elements::BackgroundImage) ? @current_background_image : Elements::BackgroundImage.new(**@current_background_image)
3287
- end
2598
+ @current_background_image.is_a?(Elements::BackgroundImage) ? @current_background_image : Elements::BackgroundImage.new(**@current_background_image)
2599
+ end
3288
2600
 
2601
+ # Sets the worksheet background image (<picture>).
2602
+ #
2603
+ # @param val [String, Hash, Elements::Image, nil] Image binary data, file path, or image options hash.
2604
+ # @return [untyped]
2605
+ # @api public
2606
+ #: (untyped val) -> untyped
2607
+ def background_image=(val)
3289
2608
  sheet if @current_sheet.nil?
2609
+ if val.nil?
2610
+ @current_background_image = nil
2611
+ return
2612
+ end
3290
2613
 
3291
- data = file_data
2614
+ data = val
3292
2615
  inferred_ext = nil
3293
2616
  if data.is_a?(String) && !data.include?("\x00") && File.file?(data)
3294
2617
  inferred_ext = File.extname(data).delete_prefix(".").downcase
@@ -3301,7 +2624,7 @@ module Xlsxrb
3301
2624
  data = data.data
3302
2625
  end
3303
2626
 
3304
- final_ext = (ext || inferred_ext || opts[:ext] || "png").to_s.delete_prefix(".").downcase
2627
+ final_ext = (inferred_ext || (val.is_a?(Hash) ? val[:ext] : nil) || "png").to_s.delete_prefix(".").downcase
3305
2628
  mime = case final_ext
3306
2629
  when "png" then "image/png"
3307
2630
  when "jpg", "jpeg" then "image/jpeg"
@@ -3312,75 +2635,49 @@ module Xlsxrb
3312
2635
  else "application/octet-stream"
3313
2636
  end
3314
2637
 
2638
+ opts = val.is_a?(Hash) ? val : {}
3315
2639
  @current_background_image = {
3316
2640
  data: data&.b,
3317
2641
  file_data: data&.b,
2642
+ extension: final_ext,
3318
2643
  ext: final_ext,
2644
+ path: "background.#{final_ext}",
3319
2645
  filename: "background.#{final_ext}",
3320
2646
  content_type: mime
3321
2647
  }.merge(opts).freeze
3322
- end
3323
- # @deprecated Use {#background_image} instead. Will be removed in 0.2.0.
3324
- alias background_picture background_image
3325
- # @deprecated Use {#background_image} instead. Will be removed in 0.2.0.
3326
- alias picture background_image
3327
-
3328
- #: (untyped val) -> untyped
3329
- def background_image=(val)
3330
- sheet if @current_sheet.nil?
3331
- if val.nil?
3332
- @current_background_image = nil
3333
- else
3334
- background_image(val)
3335
- end
3336
2648
  val
3337
2649
  end
3338
- # @deprecated Use {#background_image=} instead. Will be removed in 0.2.0.
3339
- alias background_picture= background_image=
3340
- # @deprecated Use {#background_image=} instead. Will be removed in 0.2.0.
3341
- alias picture= background_image=
3342
2650
 
3343
2651
  # Inserts a drawing shape.
3344
2652
  #
3345
2653
  # @param preset [String] Preset shape name.
3346
2654
  # @param text [String, nil] Label text.
3347
2655
  # @param from_column [Integer, nil] Top-left column.
3348
- # @param from_col [Integer, nil] Deprecated alias for from_column.
3349
2656
  # @param from_row [Integer] Top-left row.
3350
2657
  # @param to_column [Integer, nil] Bottom-right column.
3351
- # @param to_col [Integer, nil] Deprecated alias for to_column.
3352
2658
  # @param to_row [Integer] Bottom-right row.
3353
2659
  # @param opts [Hash] Additional options.
3354
2660
  # @return [void]
3355
2661
  # @api public
3356
2662
  #: (**untyped opts) -> void
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
2663
+ def shape(preset: "rect", text: nil, from_column: nil, from_row: 0, to_column: nil, to_row: 5, **opts)
2664
+ fc = from_column || 0
2665
+ tc = to_column || 5
3362
2666
  sheet if @current_sheet.nil?
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 }
2667
+ shape_data = { preset: preset, text: text, from_column: fc, from_row: from_row, to_column: tc, to_row: to_row }
3364
2668
  shape_data[:name] = opts.delete(:name) || "Shape #{@current_shapes.size + 1}"
3365
2669
  shape_data.merge!(opts)
3366
2670
  @current_shapes << shape_data
3367
2671
  end
3368
2672
 
3369
- # Gets or sets the sheet visibility state (:visible, :hidden, or :very_hidden).
2673
+ # Gets the sheet visibility state (:visible, :hidden, or :very_hidden).
3370
2674
  #
3371
- # @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#state=} instead.
3372
- # @param new_state [Symbol, nil] The new state.
3373
2675
  # @return [Symbol]
3374
2676
  # @api public
3375
- #: (?Symbol? new_state) -> Symbol
3376
- def state(new_state = nil)
2677
+ #: () -> Symbol
2678
+ def state
3377
2679
  sheet if @current_sheet.nil?
3378
- if new_state
3379
- sheet_properties(:state, new_state)
3380
- @current_sheet_state
3381
- else
3382
- @current_sheet_state || :visible
3383
- end
2680
+ @current_sheet_state || :visible
3384
2681
  end
3385
2682
 
3386
2683
  # Sets the sheet visibility state (:visible, :hidden, or :very_hidden).
@@ -3391,30 +2688,18 @@ module Xlsxrb
3391
2688
  #: (Symbol | String new_state) -> Symbol
3392
2689
  def state=(new_state)
3393
2690
  sheet if @current_sheet.nil?
3394
- sheet_properties(:state, new_state)
2691
+ sheet_properties(state: new_state)
3395
2692
  @current_sheet_state
3396
2693
  end
3397
2694
 
3398
- # Gets or sets the tab color of the current worksheet.
2695
+ # Gets the tab color of the current worksheet.
3399
2696
  #
3400
- # @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#tab_color=} instead.
3401
- # @param spec [String, Hash, Symbol, nil] Tab color hex string or hash options.
3402
- # @param opts [Hash] Color keyword arguments (e.g. theme: 1, tint: 0.5).
3403
2697
  # @return [String, Hash, nil]
3404
2698
  # @api public
3405
- #: (?String | Symbol | Hash[Symbol, untyped] | nil spec, **untyped opts) -> (String | Hash[Symbol, untyped] | nil)
3406
- def tab_color(spec = OMITTED, **opts)
2699
+ #: () -> (String | Hash[Symbol, untyped] | nil)
2700
+ def tab_color
3407
2701
  sheet if @current_sheet.nil?
3408
- if spec.equal?(OMITTED) && opts.empty?
3409
- @current_sheet_properties[:tab_color]
3410
- else
3411
- color = if opts.empty?
3412
- spec
3413
- else
3414
- spec.is_a?(Hash) ? spec.merge(opts) : opts
3415
- end
3416
- @current_sheet_properties[:tab_color] = color
3417
- end
2702
+ @current_sheet_properties[:tab_color]
3418
2703
  end
3419
2704
 
3420
2705
  # Sets the tab color of the current worksheet.
@@ -3428,51 +2713,33 @@ module Xlsxrb
3428
2713
  @current_sheet_properties[:tab_color] = spec
3429
2714
  end
3430
2715
 
3431
- # Sets a single sheet property.
3432
- #
3433
- # @param name [Symbol, String] Property name.
3434
- # @param value [Object] Property value.
3435
- # @return [void]
3436
- # @api public
3437
- #: (Symbol | String name, untyped value) -> void
3438
- def sheet_property(name, value)
3439
- sheet_properties(name, value)
3440
- end
3441
-
3442
2716
  # Configures or queries sheet properties (<sheetPr>).
3443
2717
  #
3444
2718
  # When called with no arguments, returns the {Elements::SheetProperties} value object.
3445
- # When called with arguments or keyword options, configures properties and returns nil.
2719
+ # When called with keyword options, configures properties and returns nil.
3446
2720
  #
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
2721
  # @param opts [Hash] Additional sheet properties.
3450
2722
  # @return [Elements::SheetProperties, void]
3451
2723
  # @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)
2724
+ #: () -> Elements::SheetProperties
2725
+ #: (**untyped opts) -> void
2726
+ def sheet_properties(**opts)
3454
2727
  sheet if @current_sheet.nil?
3455
- return Elements::SheetProperties.new(**@current_sheet_properties) if name.nil? && value.nil? && opts.empty?
2728
+ return Elements::SheetProperties.new(**@current_sheet_properties) if opts.empty?
3456
2729
 
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
2730
+ opts.each do |k, v|
2731
+ sym = k.to_sym
3463
2732
  if sym == :state
3464
- val = value.to_sym
2733
+ val = v.to_sym
3465
2734
  raise ArgumentError, "Invalid sheet state ':#{val}'. Allowed states are :visible, :hidden, :very_hidden" unless VALID_SHEET_STATES.include?(val)
3466
2735
 
3467
2736
  @current_sheet_state = val
3468
- return nil
3469
2737
  elsif sym == :hidden
3470
- @current_sheet_state = value ? :hidden : :visible
3471
- return nil
2738
+ @current_sheet_state = v ? :hidden : :visible
2739
+ else
2740
+ @current_sheet_properties[sym] = v
3472
2741
  end
3473
- @current_sheet_properties[name.to_sym] = value
3474
2742
  end
3475
- opts.each { |k, v| sheet_properties(k, v) }
3476
2743
  nil
3477
2744
  end
3478
2745
 
@@ -3486,30 +2753,24 @@ module Xlsxrb
3486
2753
  sheet if @current_sheet.nil?
3487
2754
  h = opts.respond_to?(:to_h) ? opts.to_h : (opts || {})
3488
2755
  @current_sheet_properties = {}
3489
- h.each { |k, v| sheet_properties(k, v) }
2756
+ sheet_properties(**h)
3490
2757
  nil
3491
2758
  end
3492
2759
 
3493
2760
  # Configures or queries sheet view display properties (<sheetView>).
3494
2761
  #
3495
2762
  # 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.
2763
+ # When called with keyword options, configures view properties and returns nil.
3497
2764
  #
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
2765
  # @param opts [Hash] Additional view properties.
3501
2766
  # @return [Elements::SheetView, void]
3502
2767
  # @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)
2768
+ #: () -> Elements::SheetView
2769
+ #: (**untyped opts) -> void
2770
+ def sheet_view(**opts)
3505
2771
  sheet if @current_sheet.nil?
3506
- return Elements::SheetView.new(**@current_sheet_view) if name.nil? && value.nil? && opts.empty?
2772
+ return Elements::SheetView.new(**@current_sheet_view) if opts.empty?
3507
2773
 
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
2774
  opts.each { |k, v| @current_sheet_view[k.to_sym] = v }
3514
2775
  nil
3515
2776
  end
@@ -3530,36 +2791,18 @@ module Xlsxrb
3530
2791
  # Configures or queries sheet format properties (<sheetFormatPr>).
3531
2792
  #
3532
2793
  # 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.
2794
+ # When called with keyword options, configures format properties and returns nil.
3534
2795
  #
3535
- # @param name [Symbol, String, Hash, Elements::MetadataRecord, nil] Property name or hash/record of properties.
3536
- # @param value [Object, nil] Property value when name is provided.
3537
2796
  # @param opts [Hash] Keyword arguments for sheet format properties.
3538
2797
  # @return [Elements::SheetFormat, void]
3539
2798
  # @api public
3540
- #: (?Symbol | String | Hash[Symbol, untyped] | Elements::MetadataRecord | nil name, ?untyped value, **untyped opts) -> (Elements::SheetFormat | void)
3541
- def sheet_format(name = nil, value = nil, **opts)
2799
+ #: () -> Elements::SheetFormat
2800
+ #: (**untyped opts) -> void
2801
+ def sheet_format(**opts)
3542
2802
  sheet if @current_sheet.nil?
3543
- return Elements::SheetFormat.new(**@current_sheet_format) if name.nil? && value.nil? && opts.empty?
2803
+ return Elements::SheetFormat.new(**@current_sheet_format) if opts.empty?
3544
2804
 
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)
3547
- elsif name && value
3548
- @current_sheet_format[name.to_sym] = value
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
3562
- @current_sheet_format.merge!(opts) unless opts.empty?
2805
+ opts.each { |k, v| @current_sheet_format[k.to_sym] = v }
3563
2806
  nil
3564
2807
  end
3565
2808
 
@@ -3572,8 +2815,7 @@ module Xlsxrb
3572
2815
  def sheet_format=(opts)
3573
2816
  sheet if @current_sheet.nil?
3574
2817
  h = opts.respond_to?(:to_h) ? opts.to_h : (opts || {})
3575
- @current_sheet_format = {}
3576
- sheet_format(h)
2818
+ @current_sheet_format = h.transform_keys(&:to_sym)
3577
2819
  nil
3578
2820
  end
3579
2821
 
@@ -3588,13 +2830,6 @@ module Xlsxrb
3588
2830
  @current_row_breaks << { id: row_index, max: 16_383, man: 1 }
3589
2831
  end
3590
2832
 
3591
- # @deprecated Use {#row_break} instead.
3592
- #: (Integer row_num) -> void
3593
- def page_break_row(row_num)
3594
- warn "[DEPRECATION] `page_break_row` is deprecated; use `row_break` instead.", uplevel: 1
3595
- row_break(row_num)
3596
- end
3597
-
3598
2833
  # Inserts a vertical page break after the given column.
3599
2834
  #
3600
2835
  # @param col [Integer, String, Symbol] 0-based column index or letter ("B", :B).
@@ -3607,13 +2842,6 @@ module Xlsxrb
3607
2842
  @current_col_breaks << { id: col_index, max: 1_048_575, man: 1 }
3608
2843
  end
3609
2844
 
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)
3615
- end
3616
-
3617
2845
  # Adds a protected range to the current sheet.
3618
2846
  #
3619
2847
  # @param name [String] Name of the protected range.
@@ -3630,8 +2858,6 @@ module Xlsxrb
3630
2858
  entry.merge!(opts) unless opts.empty?
3631
2859
  @current_protected_ranges << DslHelpers.normalize_protection_options(entry)
3632
2860
  end
3633
- # @deprecated Use {#protected_range} instead. Will be removed in 0.2.0.
3634
- alias add_protected_range protected_range
3635
2861
 
3636
2862
  # Adds a cell watch to the current sheet.
3637
2863
  #
@@ -3643,8 +2869,6 @@ module Xlsxrb
3643
2869
  sheet if @current_sheet.nil?
3644
2870
  @current_cell_watches << ref.to_s
3645
2871
  end
3646
- # @deprecated Use {#cell_watch} instead. Will be removed in 0.2.0.
3647
- alias add_cell_watch cell_watch
3648
2872
 
3649
2873
  # Adds an ignored error entry to the current sheet.
3650
2874
  #
@@ -3658,66 +2882,26 @@ module Xlsxrb
3658
2882
  @current_ignored_errors << { sqref: sqref.to_s }.merge(opts)
3659
2883
  end
3660
2884
 
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
3674
-
3675
2885
  # Returns the ignored error entries configured for the current sheet.
3676
2886
  #
3677
- # @return [Array<Hash[Symbol, untyped]>]
2887
+ # @return [Array<Elements::IgnoredError>]
3678
2888
  # @api public
3679
- #: () -> Array[Hash[Symbol, untyped]]
2889
+ #: () -> Array[Elements::IgnoredError]
3680
2890
  def ignored_errors
3681
2891
  @current_ignored_errors.map { |ie| ie.is_a?(Elements::IgnoredError) ? ie : Elements::IgnoredError.new(**ie) }.freeze
3682
2892
  end
3683
2893
 
3684
- # Gets or sets phonetic (furigana) guide properties for the current sheet.
2894
+ # Phonetic (furigana) guide properties for the current sheet.
3685
2895
  #
3686
- # @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#phonetic_properties=} instead.
3687
- # @overload phonetic_properties()
3688
- # Returns the current phonetic properties.
3689
- # @return [Hash, nil]
3690
- # @overload phonetic_properties(spec = nil, font_id: nil, type: nil, alignment: nil)
3691
- # Sets phonetic properties for the current sheet.
3692
- # @param spec [Hash, Integer, nil]
3693
- # @param font_id [Integer, nil]
3694
- # @param type [Symbol, String, nil]
3695
- # @param alignment [Symbol, String, nil]
3696
- # @return [Hash, nil]
2896
+ # @return [Elements::PhoneticProperties, nil]
3697
2897
  # @api public
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)
2898
+ #: () -> Elements::PhoneticProperties?
2899
+ def phonetic_properties
3700
2900
  sheet if @current_sheet.nil?
3701
- if spec.equal?(OMITTED) && font_id.nil? && type.nil? && alignment.nil? && opts.empty?
3702
- return nil unless @current_phonetic_properties
2901
+ return nil unless @current_phonetic_properties
3703
2902
 
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
3707
- else
3708
- props = if spec.is_a?(Hash)
3709
- spec.merge(opts)
3710
- elsif spec.is_a?(Integer)
3711
- { font_id: spec, type: type, alignment: alignment }.merge(opts)
3712
- else
3713
- { font_id: font_id, type: type, alignment: alignment }.merge(opts)
3714
- end
3715
- props.compact!
3716
- @current_phonetic_properties = WorksheetBuilder.normalize_phonetic_properties(props)
3717
- end
2903
+ @current_phonetic_properties.is_a?(Elements::PhoneticProperties) ? @current_phonetic_properties : Elements::PhoneticProperties.new(**@current_phonetic_properties)
3718
2904
  end
3719
- # @deprecated Use {#phonetic_properties} instead. Will be removed in 0.2.0.
3720
- alias phonetic_pr phonetic_properties
3721
2905
 
3722
2906
  # Sets phonetic (furigana) guide properties for the current sheet.
3723
2907
  #
@@ -3741,27 +2925,17 @@ module Xlsxrb
3741
2925
  end
3742
2926
  spec
3743
2927
  end
3744
- # @deprecated Use {#phonetic_properties=} instead. Will be removed in 0.2.0.
3745
- alias phonetic_pr= phonetic_properties=
3746
2928
 
3747
- # Sets or gets the internal code name of the current worksheet (or workbook if no sheet is open).
2929
+ # Gets the internal code name of the current worksheet (or workbook if no sheet is open).
3748
2930
  #
3749
- # @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#code_name=} instead.
3750
- # @param val [String, Symbol, nil] The code name.
3751
2931
  # @return [String, nil]
3752
2932
  # @api public
3753
- #: (?String | Symbol | nil val) -> String?
3754
- def code_name(val = OMITTED)
2933
+ #: () -> String?
2934
+ def code_name
3755
2935
  if @current_sheet.nil?
3756
- if val.equal?(OMITTED)
3757
- @workbook_properties[:code_name]
3758
- else
3759
- @workbook_properties[:code_name] = val&.to_s
3760
- end
3761
- elsif val.equal?(OMITTED)
3762
- @current_sheet_properties[:code_name]
2936
+ @workbook_properties[:code_name]
3763
2937
  else
3764
- @current_sheet_properties[:code_name] = val&.to_s
2938
+ @current_sheet_properties[:code_name]
3765
2939
  end
3766
2940
  end
3767
2941
 
@@ -3779,38 +2953,14 @@ module Xlsxrb
3779
2953
  end
3780
2954
  end
3781
2955
 
3782
- # Configures whether page setup fits content to page width/height for the current sheet.
3783
- # When enabled, optionally sets fit_to_width and/or fit_to_height on page_setup.
2956
+ # Returns whether page setup fits content to page width/height for the current sheet.
3784
2957
  #
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.
3786
- # @param enabled [Boolean, nil] Whether to fit to page.
3787
- # @param width [Integer, nil] Pages wide to fit to.
3788
- # @param height [Integer, nil] Pages tall to fit to.
3789
- # @return [Boolean, void]
3790
- # @api public
3791
- #: (?bool? enabled, ?width: Integer?, ?height: Integer?) -> (bool | void)
3792
- def fit_to_page(enabled = OMITTED, width: nil, height: nil)
3793
- sheet if @current_sheet.nil?
3794
- if enabled.equal?(OMITTED) && width.nil? && height.nil?
3795
- return @current_sheet_properties[:fit_to_page] ? true : false
3796
- end
3797
-
3798
- @current_sheet_properties[:fit_to_page] = if enabled.equal?(OMITTED)
3799
- true
3800
- else
3801
- enabled ? true : false
3802
- end
3803
- page_setup(fit_to_width: width) if width
3804
- page_setup(fit_to_height: height) if height
3805
- end
3806
-
3807
- # @deprecated Use {#fit_to_page} instead. Will be removed in 0.2.0.
3808
2958
  # @return [Boolean]
3809
2959
  # @api public
3810
2960
  #: () -> bool
3811
2961
  def fit_to_page?
3812
- warn "[Xlsxrb DEPRECATION] fit_to_page? is deprecated; use fit_to_page instead.", uplevel: 1
3813
- fit_to_page
2962
+ sheet if @current_sheet.nil?
2963
+ @current_sheet_properties[:fit_to_page] ? true : false
3814
2964
  end
3815
2965
 
3816
2966
  # Sets whether page setup fits content to page width/height for the current sheet.
@@ -3824,37 +2974,20 @@ module Xlsxrb
3824
2974
  @current_sheet_properties[:fit_to_page] = enabled ? true : false
3825
2975
  end
3826
2976
 
3827
- # Configures worksheet calculation properties (<sheetCalcPr>) for the current sheet.
2977
+ # Worksheet calculation properties (<sheetCalcPr>) for the current sheet.
3828
2978
  #
3829
2979
  # @example Instruct Excel to recalculate formulas when loading sheet
3830
2980
  # w.sheet_calc_properties = { full_calc_on_load: true }
3831
2981
  #
3832
- # @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#sheet_calc_properties=} instead.
3833
- # @param spec [Hash, nil] Calculation properties hash.
3834
- # @param full_calc_on_load [Boolean, nil] Whether to recalculate when loading.
3835
- # @return [Hash, nil]
2982
+ # @return [Elements::SheetCalcProperties, nil]
3836
2983
  # @api public
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)
2984
+ #: () -> Elements::SheetCalcProperties?
2985
+ def sheet_calc_properties
3839
2986
  sheet if @current_sheet.nil?
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
3851
- end
2987
+ calc = @current_sheet_calc_pr || (@current_sheet_properties[:full_calc_on_load] ? { full_calc_on_load: true } : nil)
2988
+ return nil unless calc
3852
2989
 
3853
- pr = spec.is_a?(Hash) ? spec.dup : {}
3854
- pr[:full_calc_on_load] = full_calc_on_load unless full_calc_on_load.nil?
3855
- pr.merge!(opts) unless opts.empty?
3856
- @current_sheet_properties[:full_calc_on_load] = pr[:full_calc_on_load] unless pr[:full_calc_on_load].nil?
3857
- @current_sheet_calc_pr = pr
2990
+ calc.is_a?(Elements::SheetCalcProperties) ? calc : Elements::SheetCalcProperties.new(**calc)
3858
2991
  end
3859
2992
 
3860
2993
  # Sets worksheet calculation properties (<sheetCalcPr>) for the current sheet.
@@ -3876,34 +3009,6 @@ module Xlsxrb
3876
3009
  spec
3877
3010
  end
3878
3011
 
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
3906
-
3907
3012
  # --- Workbook-Level Methods ---
3908
3013
 
3909
3014
  # Adds a defined name.
@@ -3913,32 +3018,17 @@ module Xlsxrb
3913
3018
  # @param sheet [String, nil] Reference sheet name.
3914
3019
  # @param scope [String, Symbol, nil] Local scope sheet name or :workbook.
3915
3020
  # @param hidden [Boolean] Whether the defined name is hidden.
3916
- # @param column [Integer, String, nil] Deprecated alias for columns.
3917
3021
  # @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.
3920
- # @param rows [Integer, Range, nil] Row or row range (1-based) for coordinate-based reference.
3022
+ # @param rows [Integer, Range, nil] Row or row range (0-based) for coordinate-based reference.
3921
3023
  # @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.
3924
3024
  # @return [void]
3925
3025
  # @api public
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?
3933
- target_ref_sheet = ref_sheet || sheet
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)
3026
+ #: (String name, ?untyped value, ?sheet: String?, ?scope: (String | Symbol)?, ?hidden: bool, ?columns: untyped, ?rows: untyped, ?range: untyped) -> void
3027
+ def defined_name(name, value = nil, sheet: nil, scope: nil, hidden: false, columns: nil, rows: nil, range: nil)
3028
+ normalized_val = DslHelpers.normalize_defined_name_value(value, sheet: sheet, columns: columns, rows: rows, range: range)
3937
3029
  entry = { name: name, value: normalized_val, hidden: hidden }
3938
3030
  local_sheet = if scope
3939
3031
  scope == :workbook ? nil : scope.to_s
3940
- elsif sheet || local || ref_sheet
3941
- sheet
3942
3032
  end
3943
3033
  if local_sheet
3944
3034
  # local_sheet_id will be resolved at close time
@@ -3956,24 +3046,20 @@ module Xlsxrb
3956
3046
  @defined_names.map { |dn| dn.is_a?(Elements::DefinedName) ? dn : Elements::DefinedName.new(**dn) }
3957
3047
  end
3958
3048
 
3959
- # Sets or gets the print area for the current or named sheet.
3049
+ # Returns the print area range for the current or named sheet, or nil if none.
3960
3050
  #
3961
- # @param range [String, Object, nil] Cell range (e.g. "A1:G50").
3962
3051
  # @param sheet [String, nil] Target sheet name.
3963
- # @return [String, nil, void]
3052
+ # @return [String, nil]
3964
3053
  # @api public
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
3970
- sheet_name = sheet || @current_sheet || "Sheet1"
3971
- @defined_names.reject! { |dn| dn[:name] == "_xlnm.Print_Area" && dn[:local_sheet_name] == sheet_name }
3972
- if range
3973
- value = "'#{sheet_name}'!#{absolute_range(range)}"
3974
- defined_name("_xlnm.Print_Area", value, sheet: sheet_name, scope: sheet_name)
3054
+ #: (?sheet: String?) -> String?
3055
+ def print_area(sheet: nil)
3056
+ sheet_name = sheet || @current_sheet
3057
+ if sheet_name.nil? || sheet_name == @current_sheet
3058
+ @current_print_area
3059
+ else
3060
+ dn = @defined_names.find { |d| d[:name] == "_xlnm.Print_Area" && d[:local_sheet_name] == sheet_name }
3061
+ dn ? dn[:value].split("!", 2).last.tr("$", "") : nil
3975
3062
  end
3976
- nil
3977
3063
  end
3978
3064
 
3979
3065
  # Sets the print area for the current worksheet.
@@ -3983,38 +3069,37 @@ module Xlsxrb
3983
3069
  # @api public
3984
3070
  #: (String? range) -> String?
3985
3071
  def print_area=(range)
3986
- print_area(range)
3987
- range
3072
+ set_print_area(range, sheet: @current_sheet)
3988
3073
  end
3989
3074
 
3990
- # Sets or gets print titles for the current or named sheet.
3075
+ # Sets or gets repeating print titles (rows and/or columns) for pagination.
3076
+ #
3077
+ # When called with no row/column arguments, returns the {Elements::PrintTitles} value object or nil.
3078
+ # When called with row/column arguments, sets repeating print titles and returns nil.
3991
3079
  #
3992
3080
  # @param rows [String, Integer, Range, Object, nil] Repeating row range (e.g. "1:2" or 0-based 0..1).
3993
3081
  # @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.
3995
3082
  # @param sheet [String, nil] Target sheet name.
3996
3083
  # @return [Elements::PrintTitles, nil, void]
3997
3084
  # @api public
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
3085
+ #: () -> Elements::PrintTitles?
3086
+ #: (?rows: (String | Integer | Range[Integer])?, ?columns: (String | Integer | Symbol | Range[untyped])?, ?sheet: String?) -> void
3087
+ def print_titles(rows: nil, columns: nil, sheet: nil)
3088
+ sheet_name = sheet || @current_sheet || "Sheet1"
3089
+ if rows.nil? && columns.nil?
3090
+ return Elements::PrintTitles.new(rows: @current_print_titles[:rows], columns: @current_print_titles[:columns]) if sheet_name == @current_sheet && @current_print_titles
4002
3091
 
4003
- return Elements::PrintTitles.new(rows: @current_print_titles[:rows], columns: @current_print_titles[:columns] || @current_print_titles[:cols])
4004
- end
3092
+ existing = @defined_names.find { |dn| dn[:name] == "_xlnm.Print_Titles" && dn[:local_sheet_name] == sheet_name }
3093
+ return nil unless existing
4005
3094
 
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
3095
+ c = Regexp.last_match(1).delete("$") if existing[:value] =~ /'[^']*'!\$([A-Za-z]+:\$[A-Za-z]+)/
3096
+ r = Regexp.last_match(1).delete("$") if existing[:value] =~ /'[^']*'!\$([0-9]+:\$[0-9]+)/
3097
+ return Elements::PrintTitles.new(rows: r, columns: c)
3098
+ end
4014
3099
 
4015
- c = DslHelpers.normalize_print_titles_columns(c_val)
4016
- r = DslHelpers.normalize_print_titles_rows(r_val)
4017
- sheet_name = sheet || @current_sheet || "Sheet1"
3100
+ @current_print_titles = { rows: rows, columns: columns }.compact if sheet_name == @current_sheet
3101
+ c = DslHelpers.normalize_print_titles_columns(columns)
3102
+ r = DslHelpers.normalize_print_titles_rows(rows)
4018
3103
  existing = @defined_names.find { |dn| dn[:name] == "_xlnm.Print_Titles" && dn[:local_sheet_name] == sheet_name }
4019
3104
  if existing && (r.nil? || c.nil?)
4020
3105
  c = Regexp.last_match(1).delete("$") if c.nil? && existing[:value] =~ /'[^']*'!\$([A-Za-z]+:\$[A-Za-z]+)/
@@ -4106,7 +3191,7 @@ module Xlsxrb
4106
3191
  if opts.empty?
4107
3192
  @workbook_protection ? Elements::WorkbookProtection.new(**@workbook_protection) : nil
4108
3193
  else
4109
- @workbook_protection = opts
3194
+ @workbook_protection = DslHelpers.normalize_workbook_protection(opts)
4110
3195
  nil
4111
3196
  end
4112
3197
  end
@@ -4118,58 +3203,69 @@ module Xlsxrb
4118
3203
  # @api public
4119
3204
  #: (untyped opts) -> void
4120
3205
  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.
4125
- #: (**String | Integer | bool | nil opts) -> void
4126
- def protect_workbook(...)
4127
- warn "[DEPRECATION] `protect_workbook` is deprecated; use `workbook_protection` instead.", uplevel: 1
4128
- workbook_protection(...)
3206
+ @workbook_protection = opts.is_a?(Elements::MetadataRecord) ? opts.to_h : (opts && DslHelpers.normalize_workbook_protection(opts))
4129
3207
  end
4130
3208
 
4131
- # Sets a core document metadata property.
3209
+ # Configures or queries core document properties.
4132
3210
  #
4133
- # @param name [Symbol] Property name.
4134
- # @param value [String, Integer, Time] Property value.
4135
- # @return [void]
4136
- # @api public
4137
- #: (Symbol name, String | Integer | Time value) -> void
4138
- def core_property(name, value)
4139
- @core_properties[name] = value
4140
- end
4141
-
4142
- # Returns core document properties.
3211
+ # When called with no arguments, returns the {Elements::CoreProperties} value object.
3212
+ # When called with keyword options, configures properties and returns nil.
4143
3213
  #
4144
- # @return [Elements::CoreProperties]
3214
+ # @param opts [Hash] Core properties map.
3215
+ # @return [Elements::CoreProperties, void]
4145
3216
  # @api public
4146
3217
  #: () -> Elements::CoreProperties
4147
- def core_properties
4148
- Elements::CoreProperties.new(**@core_properties)
3218
+ #: (**untyped opts) -> void
3219
+ def core_properties(**opts)
3220
+ return Elements::CoreProperties.new(**@core_properties) if opts.empty?
3221
+
3222
+ @core_properties.merge!(opts)
3223
+ nil
4149
3224
  end
4150
3225
 
4151
- # Sets an app document property.
3226
+ # Replaces core document properties.
4152
3227
  #
4153
- # @param name [Symbol] Property name.
4154
- # @param value [String, Integer, Time] Property value.
3228
+ # @param props [Hash, Elements::CoreProperties]
4155
3229
  # @return [void]
4156
3230
  # @api public
4157
- #: (Symbol name, String | Integer | Time value) -> void
4158
- def app_property(name, value)
4159
- # simplecov:disable
4160
- # Edge case / untested delegation block
4161
- norm_name = name.to_sym == :application ? :app_name : name.to_sym
4162
- @app_properties[norm_name] = value
4163
- # simplecov:enable
3231
+ #: (Hash[Symbol, untyped] | Elements::CoreProperties props) -> void
3232
+ def core_properties=(props)
3233
+ h = props.respond_to?(:to_h) ? props.to_h : (props || {})
3234
+ @core_properties = h.transform_keys(&:to_sym)
3235
+ nil
4164
3236
  end
4165
3237
 
4166
- # Returns application document properties.
3238
+ # Configures or queries application document properties.
3239
+ #
3240
+ # When called with no arguments, returns the {Elements::AppProperties} value object.
3241
+ # When called with keyword options, configures properties and returns nil.
4167
3242
  #
4168
- # @return [Elements::AppProperties]
3243
+ # @param opts [Hash] Application properties map.
3244
+ # @return [Elements::AppProperties, void]
4169
3245
  # @api public
4170
3246
  #: () -> Elements::AppProperties
4171
- def app_properties
4172
- Elements::AppProperties.new(**@app_properties)
3247
+ #: (**untyped opts) -> void
3248
+ def app_properties(**opts)
3249
+ return Elements::AppProperties.new(**@app_properties) if opts.empty?
3250
+
3251
+ opts.each do |k, v|
3252
+ norm_name = k.to_sym == :application ? :app_name : k.to_sym
3253
+ @app_properties[norm_name] = v
3254
+ end
3255
+ nil
3256
+ end
3257
+
3258
+ # Replaces application document properties.
3259
+ #
3260
+ # @param props [Hash, Elements::AppProperties]
3261
+ # @return [void]
3262
+ # @api public
3263
+ #: (Hash[Symbol, untyped] | Elements::AppProperties props) -> void
3264
+ def app_properties=(props)
3265
+ h = props.respond_to?(:to_h) ? props.to_h : (props || {})
3266
+ @app_properties = {}
3267
+ app_properties(**h)
3268
+ nil
4173
3269
  end
4174
3270
 
4175
3271
  # Sets multiple core and/or app properties.
@@ -4181,12 +3277,9 @@ module Xlsxrb
4181
3277
  # @api public
4182
3278
  #: (?core: Hash[Symbol, String | Integer | Time]?, ?app: Hash[Symbol, String | Integer | Time]?, ?custom: Hash[String | Symbol, untyped]?) -> void
4183
3279
  def properties(core: nil, app: nil, custom: nil)
4184
- # simplecov:disable
4185
- # Edge case / untested delegation block
4186
- core&.each { |k, v| core_property(k, v) }
4187
- app&.each { |k, v| app_property(k, v) }
3280
+ core_properties(**core) if core
3281
+ app_properties(**app) if app
4188
3282
  custom&.each { |k, v| custom_property(k.to_s, v) }
4189
- # simplecov:enable
4190
3283
  end
4191
3284
 
4192
3285
  # Adds a custom document property.
@@ -4240,7 +3333,7 @@ module Xlsxrb
4240
3333
  resolved_names = resolve_defined_names(@defined_names, @sheets)
4241
3334
 
4242
3335
  @workbook_properties[:active_sheet] = @active_sheet unless @active_sheet.nil?
4243
- @workbook_properties[:active_tab] = @active_sheet unless @active_sheet.nil?
3336
+ @workbook_properties[:active_sheet_index] = @active_sheet unless @active_sheet.nil?
4244
3337
  @workbook_properties[:first_sheet] = @first_sheet unless @first_sheet.nil?
4245
3338
  @workbook_properties[:show_sheet_tabs] = @show_sheet_tabs unless @show_sheet_tabs.nil?
4246
3339
  @workbook_properties[:tab_ratio] = @tab_ratio unless @tab_ratio.nil?
@@ -4289,6 +3382,59 @@ module Xlsxrb
4289
3382
 
4290
3383
  private
4291
3384
 
3385
+ # Raises ArgumentError for any cell style name that has not been defined.
3386
+ #: (untyped cell_styles) -> void
3387
+ def check_style_names!(cell_styles)
3388
+ if cell_styles.is_a?(Array)
3389
+ cell_styles.each { |name| DslHelpers.check_style_name!(name, @style_name_to_id) }
3390
+ else
3391
+ DslHelpers.check_style_name!(cell_styles, @style_name_to_id)
3392
+ end
3393
+ end
3394
+
3395
+ # Gives Date and Time values whose named cell style has no number format a variant of
3396
+ # that style with the default date or time format, registered on first use.
3397
+ #: (Array[untyped] values, untyped cell_styles) -> untyped
3398
+ def with_date_style_variants(values, cell_styles)
3399
+ styles_for_cells = cell_styles.is_a?(Array) ? cell_styles : nil
3400
+ values.each_with_index do |value, idx|
3401
+ next unless value.is_a?(Date) || value.is_a?(Time)
3402
+
3403
+ style_name = styles_for_cells ? styles_for_cells[idx] : cell_styles
3404
+ next unless style_name.is_a?(String) || style_name.is_a?(Symbol)
3405
+
3406
+ variant = DslHelpers.date_style_variant(value, style_name.to_s, @styles[style_name.to_s])
3407
+ next unless variant
3408
+
3409
+ variant_name, number_format = variant
3410
+ unless @style_name_to_id.key?(variant_name)
3411
+ variant_builder = @styles[style_name.to_s].with_number_format(variant_name, number_format)
3412
+ @styles[variant_name] = variant_builder
3413
+ @style_name_to_id[variant_name] = variant_builder.register_with(@style_writer)
3414
+ end
3415
+ styles_for_cells ||= Array.new(values.size, cell_styles)
3416
+ styles_for_cells = styles_for_cells.dup if styles_for_cells.equal?(cell_styles)
3417
+ styles_for_cells[idx] = variant_name
3418
+ end
3419
+ styles_for_cells || cell_styles
3420
+ end
3421
+
3422
+ def ensure_sheet_started!
3423
+ sheet if @current_sheet.nil?
3424
+ end
3425
+
3426
+ #: (String? range, ?sheet: String?) -> String?
3427
+ def set_print_area(range, sheet: nil)
3428
+ sheet_name = sheet || @current_sheet || "Sheet1"
3429
+ @current_print_area = range&.to_s if sheet_name == @current_sheet
3430
+ @defined_names.reject! { |dn| dn[:name] == "_xlnm.Print_Area" && dn[:local_sheet_name] == sheet_name }
3431
+ if range
3432
+ value = "'#{sheet_name}'!#{absolute_range(range)}"
3433
+ defined_name("_xlnm.Print_Area", value, sheet: sheet_name, scope: sheet_name)
3434
+ end
3435
+ range&.to_s
3436
+ end
3437
+
4292
3438
  #: (untyped range) -> untyped
4293
3439
  def absolute_range(range)
4294
3440
  DslHelpers.absolute_range(range)
@@ -4316,7 +3462,7 @@ module Xlsxrb
4316
3462
  unless @current_conditional_formats.empty?
4317
3463
  @dxfs ||= []
4318
3464
  @current_conditional_formats = @current_conditional_formats.map do |rule|
4319
- next rule if rule.respond_to?(:dxf_id) ? rule.dxf_id : (rule.is_a?(Hash) && (rule[:dxf_id] || rule[:format_id]))
3465
+ next rule if rule[:dxf_id] || rule[:format_id]
4320
3466
 
4321
3467
  normalized = rule.dup
4322
3468
  dxf = normalized.delete(:dxf) || DslHelpers.extract_dxf_from_rule!(normalized)
@@ -4328,7 +3474,6 @@ module Xlsxrb
4328
3474
  dxf_id = @dxfs.size - 1
4329
3475
  end
4330
3476
  normalized[:dxf_id] = dxf_id
4331
- normalized[:format_id] = dxf_id
4332
3477
  normalized
4333
3478
  end
4334
3479
  end
@@ -4366,7 +3511,7 @@ module Xlsxrb
4366
3511
  sheet_format: @current_sheet_format,
4367
3512
  sheet_view: @current_sheet_view,
4368
3513
  row_breaks: @current_row_breaks,
4369
- col_breaks: @current_col_breaks,
3514
+ column_breaks: @current_col_breaks,
4370
3515
  protected_ranges: @current_protected_ranges,
4371
3516
  cell_watches: @current_cell_watches,
4372
3517
  ignored_errors: @current_ignored_errors,
@@ -4377,8 +3522,10 @@ module Xlsxrb
4377
3522
  sheet_data[:cells] = @current_cells if @current_cells && !@current_cells.empty?
4378
3523
  @current_cells = nil
4379
3524
 
4380
- temp_wb_writer = Ooxml::WorkbookWriter.new(sheets: [sheet_data])
4381
- info = temp_wb_writer.prepare_sheet_auxiliary(sheet_data, @current_sheet_index - 1)
3525
+ # One writer for all sheets, so that drawing, comment, table, and pivot part numbers
3526
+ # continue across sheets as write_package_parts numbers the parts.
3527
+ @auxiliary_writer ||= Ooxml::WorkbookWriter.new(sheets: [])
3528
+ info = @auxiliary_writer.prepare_sheet_auxiliary(sheet_data, @current_sheet_index - 1)
4382
3529
 
4383
3530
  @current_row_writer.finish(
4384
3531
  drawing_rid: info[:drawing_rid],
@@ -4397,7 +3544,7 @@ module Xlsxrb
4397
3544
  page_setup: @current_page_setup.empty? ? nil : @current_page_setup,
4398
3545
  header_footer: @current_header_footer.empty? ? nil : @current_header_footer,
4399
3546
  row_breaks: @current_row_breaks.empty? ? nil : @current_row_breaks,
4400
- col_breaks: @current_col_breaks.empty? ? nil : @current_col_breaks,
3547
+ column_breaks: @current_col_breaks.empty? ? nil : @current_col_breaks,
4401
3548
  cell_watches: @current_cell_watches.empty? ? nil : @current_cell_watches,
4402
3549
  ignored_errors: @current_ignored_errors.empty? ? nil : @current_ignored_errors,
4403
3550
  phonetic_pr: @current_phonetic_properties,