xlsxrb 0.1.13 → 0.1.15

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 (71) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +104 -0
  3. data/README.md +17 -14
  4. data/lib/xlsxrb/colors.rb +118 -0
  5. data/lib/xlsxrb/elements/cell.rb +205 -16
  6. data/lib/xlsxrb/elements/column.rb +6 -4
  7. data/lib/xlsxrb/elements/coordinate_access.rb +32 -0
  8. data/lib/xlsxrb/elements/image.rb +128 -0
  9. data/lib/xlsxrb/elements/row.rb +206 -9
  10. data/lib/xlsxrb/elements/styles.rb +157 -0
  11. data/lib/xlsxrb/elements/types.rb +95 -1
  12. data/lib/xlsxrb/elements/workbook.rb +121 -4
  13. data/lib/xlsxrb/elements/worksheet.rb +519 -29
  14. data/lib/xlsxrb/elements.rb +2 -0
  15. data/lib/xlsxrb/number_formatter.rb +429 -0
  16. data/lib/xlsxrb/ooxml/cfb.rb +1 -1
  17. data/lib/xlsxrb/ooxml/reader/listeners/core_listeners.rb +7 -5
  18. data/lib/xlsxrb/ooxml/reader/listeners/drawing_listeners.rb +11 -4
  19. data/lib/xlsxrb/ooxml/reader/listeners/feature_listeners.rb +7 -1
  20. data/lib/xlsxrb/ooxml/reader.rb +14 -17
  21. data/lib/xlsxrb/ooxml/shared_strings_parser.rb +7 -1
  22. data/lib/xlsxrb/ooxml/styles_parser.rb +39 -9
  23. data/lib/xlsxrb/ooxml/utils.rb +34 -18
  24. data/lib/xlsxrb/ooxml/workbook_parser.rb +74 -16
  25. data/lib/xlsxrb/ooxml/workbook_writer.rb +82 -23
  26. data/lib/xlsxrb/ooxml/worksheet_parser.rb +319 -79
  27. data/lib/xlsxrb/ooxml/worksheet_writer.rb +263 -66
  28. data/lib/xlsxrb/ooxml/writer/features_xml.rb +5 -3
  29. data/lib/xlsxrb/ooxml/writer.rb +14 -0
  30. data/lib/xlsxrb/ooxml/xml_builder.rb +14 -2
  31. data/lib/xlsxrb/ooxml/zip_reader.rb +144 -28
  32. data/lib/xlsxrb/stream_row.rb +243 -16
  33. data/lib/xlsxrb/stream_sheet.rb +647 -16
  34. data/lib/xlsxrb/stream_writer.rb +375 -34
  35. data/lib/xlsxrb/style_builder.rb +308 -22
  36. data/lib/xlsxrb/utils.rb +211 -0
  37. data/lib/xlsxrb/version.rb +1 -1
  38. data/lib/xlsxrb/workbook_builder.rb +72 -11
  39. data/lib/xlsxrb/worksheet_builder.rb +738 -24
  40. data/lib/xlsxrb.rb +1073 -83
  41. data/sig/generated/xlsxrb/colors.rbs +40 -0
  42. data/sig/generated/xlsxrb/elements/cell.rbs +113 -8
  43. data/sig/generated/xlsxrb/elements/column.rbs +3 -2
  44. data/sig/generated/xlsxrb/elements/coordinate_access.rbs +18 -0
  45. data/sig/generated/xlsxrb/elements/image.rbs +82 -0
  46. data/sig/generated/xlsxrb/elements/row.rbs +83 -4
  47. data/sig/generated/xlsxrb/elements/styles.rbs +79 -0
  48. data/sig/generated/xlsxrb/elements/types.rbs +43 -0
  49. data/sig/generated/xlsxrb/elements/workbook.rbs +79 -2
  50. data/sig/generated/xlsxrb/elements/worksheet.rbs +282 -18
  51. data/sig/generated/xlsxrb/number_formatter.rbs +132 -0
  52. data/sig/generated/xlsxrb/ooxml/reader.rbs +6 -0
  53. data/sig/generated/xlsxrb/ooxml/shared_strings_parser.rbs +2 -0
  54. data/sig/generated/xlsxrb/ooxml/styles_parser.rbs +5 -2
  55. data/sig/generated/xlsxrb/ooxml/utils.rbs +17 -8
  56. data/sig/generated/xlsxrb/ooxml/workbook_parser.rbs +9 -3
  57. data/sig/generated/xlsxrb/ooxml/workbook_writer.rbs +1 -1
  58. data/sig/generated/xlsxrb/ooxml/worksheet_parser.rbs +28 -6
  59. data/sig/generated/xlsxrb/ooxml/worksheet_writer.rbs +13 -3
  60. data/sig/generated/xlsxrb/ooxml/writer.rbs +2 -0
  61. data/sig/generated/xlsxrb/ooxml/xml_builder.rbs +3 -1
  62. data/sig/generated/xlsxrb/ooxml/zip_reader.rbs +13 -0
  63. data/sig/generated/xlsxrb/stream_row.rbs +100 -6
  64. data/sig/generated/xlsxrb/stream_sheet.rbs +358 -14
  65. data/sig/generated/xlsxrb/stream_writer.rbs +220 -30
  66. data/sig/generated/xlsxrb/style_builder.rbs +55 -18
  67. data/sig/generated/xlsxrb/utils.rbs +151 -0
  68. data/sig/generated/xlsxrb/workbook_builder.rbs +26 -0
  69. data/sig/generated/xlsxrb/worksheet_builder.rbs +356 -18
  70. data/sig/generated/xlsxrb.rbs +223 -27
  71. metadata +11 -1
@@ -123,12 +123,24 @@ module Xlsxrb
123
123
  # @param hidden [Boolean] Whether the row is hidden.
124
124
  # @param custom_height [Boolean] Whether to flag as custom height.
125
125
  # @param outline_level [Integer, nil] Grouping/outline level (0 - 7).
126
+ # @param collapsed [Boolean] Whether the row is collapsed.
126
127
  # @return [void]
127
128
  # @api public
128
- # : (Array[untyped] | Hash[untyped, untyped] values, ?styles: untyped, ?height: Float | Integer | nil, ?hidden: bool, ?custom_height: bool, ?outline_level: Integer | nil) -> void
129
- def row: (Array[untyped] | Hash[untyped, untyped] values, ?styles: untyped, ?height: Float | Integer | nil, ?hidden: bool, ?custom_height: bool, ?outline_level: Integer | nil) -> void
129
+ # : (Array[untyped] | Hash[untyped, untyped] values, ?styles: untyped, ?height: Float | Integer | nil, ?hidden: bool, ?custom_height: bool, ?collapsed: bool, ?outline_level: Integer | nil) -> void
130
+ def row: (Array[untyped] | Hash[untyped, untyped] values, ?styles: untyped, ?height: Float | Integer | nil, ?hidden: bool, ?custom_height: bool, ?collapsed: bool, ?outline_level: Integer | nil) -> void
130
131
 
131
- alias << row
132
+ alias add_row row
133
+
134
+ # Appends a row to the worksheet and returns self for chaining.
135
+ #
136
+ # @example
137
+ # sheet << ["A", 1] << ["B", 2]
138
+ #
139
+ # @param values [Array, Hash] Row cell values.
140
+ # @return [self]
141
+ # @api public
142
+ # : (Array[untyped] | Hash[untyped, untyped] values) -> self
143
+ def <<: (Array[untyped] | Hash[untyped, untyped] values) -> self
132
144
 
133
145
  # Configures column width and properties.
134
146
  #
@@ -179,8 +191,8 @@ module Xlsxrb
179
191
  # @param location [String, nil] Destination location / URL (keyword alternative).
180
192
  # @return [void]
181
193
  # @api public
182
- # : (String cell, ?String? url, ?display: String?, ?tooltip: String?, ?location: String?) -> void
183
- def hyperlink: (String cell, ?String? url, ?display: String?, ?tooltip: String?, ?location: String?) -> void
194
+ # : (String | Integer cell, ?(String | Elements::Hyperlink)? url, ?display: String?, ?tooltip: String?, ?location: String?) -> void
195
+ def hyperlink: (String | Integer cell, ?(String | Elements::Hyperlink)? url, ?display: String?, ?tooltip: String?, ?location: String?) -> void
184
196
 
185
197
  # Sets the auto-filter range on the active sheet.
186
198
  #
@@ -220,16 +232,25 @@ module Xlsxrb
220
232
 
221
233
  # Adds data validation rules to a range.
222
234
  #
235
+ # Adds data validation to a cell or range.
236
+ #
223
237
  # @example Dropdown list validation
224
238
  # s.validate_data("B2:B100", type: "list", formula1: '"High,Medium,Low"')
225
239
  #
226
- # @param range [String] The cell range (e.g. "B2:B10").
227
- # @param type [String, Symbol] Validation type ("list", "whole", "decimal", "date", "time", "textLength", "custom").
240
+ # @example Block syntax
241
+ # s.validate_data("B2:B100") do |dv|
242
+ # dv.type :list
243
+ # dv.formula1 '"High,Medium,Low"'
244
+ # end
245
+ #
246
+ # @param range [String, nil] The cell range (e.g. "B2:B10").
247
+ # @param type [String, Symbol, nil] Validation type ("list", "whole", "decimal", "date", "time", "textLength", "custom").
228
248
  # @param opts [Hash] Validation options.
249
+ # @yield [data_validation_builder] Optional configuration block.
229
250
  # @return [void]
230
251
  # @api public
231
- # : (String range, ?type: String | Symbol, **untyped opts) -> void
232
- def validate_data: (String range, ?type: String | Symbol, **untyped opts) -> void
252
+ # : (?String? range, ?type: (String | Symbol)?, **untyped opts) ?{ (DataValidationBuilder) -> void } -> void
253
+ def validate_data: (?String? range, ?type: (String | Symbol)?, **untyped opts) ?{ (DataValidationBuilder) -> void } -> void
233
254
 
234
255
  # Adds conditional formatting to a range.
235
256
  #
@@ -246,19 +267,26 @@ module Xlsxrb
246
267
 
247
268
  # Adds a formatted Excel Table to the sheet.
248
269
  #
249
- # @example
270
+ # @example Standard keyword arguments
250
271
  # s.table("A1:C10", columns: ["ID", "Name", "Total"], name: "SalesTable", style: "TableStyleMedium9")
251
272
  #
252
- # @param ref [String] The cell range for the table (e.g. "A1:D10").
253
- # @param columns [Array<String>, Array<Hash>] Column names or definitions.
273
+ # @example Block syntax
274
+ # s.table("A1:C10") do |t|
275
+ # t.columns ["ID", "Name", "Total"]
276
+ # t.style "TableStyleMedium9"
277
+ # end
278
+ #
279
+ # @param ref [String, nil] The cell range for the table (e.g. "A1:D10").
280
+ # @param columns [Array<String>, Array<Hash>, nil] Column names or definitions.
254
281
  # @param name [String, nil] Table name.
255
282
  # @param display_name [String, nil] Display name.
256
283
  # @param style [String, nil] Table style name.
257
284
  # @param opts [Hash] Additional options.
285
+ # @yield [table_builder] Optional configuration block.
258
286
  # @return [void]
259
287
  # @api public
260
- # : (String ref, columns: untyped, ?name: String?, ?display_name: String?, ?style: String?, **untyped opts) -> void
261
- def table: (String ref, columns: untyped, ?name: String?, ?display_name: String?, ?style: String?, **untyped opts) -> void
288
+ # : (?String? ref, ?columns: untyped, ?name: String?, ?display_name: String?, ?style: String?, **untyped opts) ?{ (TableBuilder) -> void } -> void
289
+ def table: (?String? ref, ?columns: untyped, ?name: String?, ?display_name: String?, ?style: String?, **untyped opts) ?{ (TableBuilder) -> void } -> void
262
290
 
263
291
  # simplecov:disable
264
292
  # Edge case / untested delegation block
@@ -307,6 +335,26 @@ module Xlsxrb
307
335
  # : (sparklines: Array[Hash[Symbol, untyped]], ?type: (String | Symbol)?, **untyped opts) -> void
308
336
  def sparkline_group: (sparklines: Array[Hash[Symbol, untyped]], ?type: (String | Symbol)?, **untyped opts) -> void
309
337
 
338
+ # Adds a single sparkline to the sheet.
339
+ #
340
+ # @example Add a line sparkline
341
+ # s.add_sparkline(location: "F1", range: "A1:E1")
342
+ #
343
+ # @example Add a column sparkline with high/low markers
344
+ # s.add_sparkline(location: "F2", range: "A2:E2", type: :column, high: true, low: true)
345
+ #
346
+ # @example Add a win/loss sparkline
347
+ # s.add_sparkline(location: "F3", range: "A3:E3", type: :win_loss)
348
+ #
349
+ # @param location [String, nil] Target cell for the sparkline (e.g. "F1").
350
+ # @param range [String, nil] Data range for the sparkline (e.g. "A1:E1").
351
+ # @param type [Symbol, String, nil] Sparkline type (:line, :column, :win_loss / :stacked).
352
+ # @param opts [Hash] Additional sparkline options.
353
+ # @return [void]
354
+ # @api public
355
+ # : (?location: String?, ?range: String?, ?type: (String | Symbol)?, **untyped opts) -> void
356
+ def add_sparkline: (?location: String?, ?range: String?, ?type: (String | Symbol)?, **untyped opts) -> void
357
+
310
358
  # Sets workbook-level properties.
311
359
  #
312
360
  # @param opts [Hash] Workbook property options.
@@ -377,6 +425,24 @@ module Xlsxrb
377
425
  # : (?rows: String?, ?cols: String?) -> void
378
426
  def print_titles: (?rows: String?, ?cols: String?) -> void
379
427
 
428
+ # Sets repeating title rows to appear at the top of each printed page.
429
+ #
430
+ # @param first [Integer, String] First row index (0-based) or range string (e.g. "1:2").
431
+ # @param last [Integer, String, nil] Optional last row index (0-based).
432
+ # @return [void]
433
+ # @api public
434
+ # : (Integer | String first, ?(Integer | String)? last) -> void
435
+ def repeat_rows: (Integer | String first, ?(Integer | String)? last) -> void
436
+
437
+ # Sets repeating title columns to appear at the left of each printed page.
438
+ #
439
+ # @param first [Integer, String] First column index (0-based) or column name/range.
440
+ # @param last [Integer, String, nil] Optional last column index/name.
441
+ # @return [void]
442
+ # @api public
443
+ # : (Integer | String first, ?(Integer | String)? last) -> void
444
+ def repeat_columns: (Integer | String first, ?(Integer | String)? last) -> void
445
+
380
446
  # Splits sheet view into panes.
381
447
  #
382
448
  # @param x_split [Numeric, nil] Horizontal split position.
@@ -525,6 +591,16 @@ module Xlsxrb
525
591
  # : (Symbol | String name, untyped value) -> void
526
592
  def sheet_view: (Symbol | String name, untyped value) -> void
527
593
 
594
+ # Configures sheet format properties (e.g. default_row_height, default_col_width).
595
+ #
596
+ # @param name [Symbol, String, Hash, nil] Property name or hash of properties.
597
+ # @param value [Object, nil] Property value when name is provided.
598
+ # @param opts [Hash] Keyword arguments for sheet format properties.
599
+ # @return [Hash[Symbol, untyped]]
600
+ # @api public
601
+ # : (?Symbol | String | Hash[Symbol, untyped] | nil name, ?untyped value, **untyped opts) -> Hash[Symbol, untyped]
602
+ def sheet_format: (?Symbol | String | Hash[Symbol, untyped] | nil name, ?untyped value, **untyped opts) -> Hash[Symbol, untyped]
603
+
528
604
  # simplecov:disable
529
605
  # Edge case / untested delegation block
530
606
  # Adds a horizontal page break after the given row index.
@@ -544,6 +620,29 @@ module Xlsxrb
544
620
  # @api public
545
621
  # : (Integer col_index) -> void
546
622
  def page_break_col: (Integer col_index) -> void
623
+
624
+ # Adds a protected range to the sheet.
625
+ #
626
+ # @param name [String] Name of the protected range.
627
+ # @param sqref [String] Cell range (e.g. "A1:B10").
628
+ # @param password [String, nil] Optional password or hash.
629
+ # @param opts [Hash] Additional options.
630
+ # @return [void]
631
+ # @api public
632
+ # : (String name, String sqref, ?password: String?, **untyped opts) -> void
633
+ def protected_range: (String name, String sqref, ?password: String?, **untyped opts) -> void
634
+
635
+ alias add_protected_range protected_range
636
+
637
+ # Adds a cell watch to the sheet.
638
+ #
639
+ # @param ref [String] Cell reference (e.g. "A1").
640
+ # @return [void]
641
+ # @api public
642
+ # : (String ref) -> void
643
+ def cell_watch: (String ref) -> void
644
+
645
+ alias add_cell_watch cell_watch
547
646
  end
548
647
 
549
648
  # Adds a new sheet to the workbook and starts streaming rows into it.
@@ -573,22 +672,32 @@ module Xlsxrb
573
672
  # @param outline_level [Integer, nil] Grouping/outline level (0 - 7).
574
673
  # @return [void]
575
674
  # @api public
576
- # : (Array[untyped] | Hash[untyped, untyped] values, ?styles: untyped, ?height: Float | Integer | nil, ?hidden: bool, ?custom_height: bool, ?outline_level: Integer | nil) -> void
577
- def row: (Array[untyped] | Hash[untyped, untyped] values, ?styles: untyped, ?height: Float | Integer | nil, ?hidden: bool, ?custom_height: bool, ?outline_level: Integer | nil) -> void
675
+ # : (Array[untyped] | Hash[untyped, untyped] values, ?styles: untyped, ?height: Float | Integer | nil, ?hidden: bool, ?custom_height: bool, ?collapsed: bool, ?outline_level: Integer | nil) -> void
676
+ def row: (Array[untyped] | Hash[untyped, untyped] values, ?styles: untyped, ?height: Float | Integer | nil, ?hidden: bool, ?custom_height: bool, ?collapsed: bool, ?outline_level: Integer | nil) -> void
677
+
678
+ alias add_row row
578
679
 
579
- alias << row
680
+ # Appends a row to the worksheet and returns self for chaining.
681
+ #
682
+ # @example
683
+ # writer << ["A", 1] << ["B", 2]
684
+ #
685
+ # @param values [Array, Hash] Row cell values.
686
+ # @return [self]
687
+ # @api public
688
+ # : (Array[untyped] | Hash[untyped, untyped] values) -> self
689
+ def <<: (Array[untyped] | Hash[untyped, untyped] values) -> self
580
690
 
581
691
  # Sets column formatting and properties for one or multiple columns.
582
692
  #
583
693
  # @param index [Integer, String, Range, Array] Column index (0-based) or letter ("A".."D").
584
694
  # @param width [Float, Integer, nil] Column width in character units (0 - 255).
585
695
  # @param hidden [Boolean] Whether the column is hidden.
586
- # @param custom_width [Boolean] Whether custom width is set.
587
- # @param outline_level [Integer, nil] Grouping/outline level.
696
+ # @param style [Integer, Symbol, String, nil] Column style format or index.
588
697
  # @return [void]
589
698
  # @api public
590
- # : (Integer | String | Range[Integer | String] | Array[Integer | String] index, ?width: Float | Integer | nil, ?hidden: bool, ?custom_width: bool, ?outline_level: Integer | nil) -> void
591
- def column: (Integer | String | Range[Integer | String] | Array[Integer | String] index, ?width: Float | Integer | nil, ?hidden: bool, ?custom_width: bool, ?outline_level: Integer | nil) -> void
699
+ # : (Integer | String | Range[Integer | String] | Array[Integer | String] index, ?width: Float | Integer | nil, ?hidden: bool, ?custom_width: bool, ?outline_level: Integer | nil, ?style: (Integer | Symbol | String)?) -> void
700
+ def column: (Integer | String | Range[Integer | String] | Array[Integer | String] index, ?width: Float | Integer | nil, ?hidden: bool, ?custom_width: bool, ?outline_level: Integer | nil, ?style: (Integer | Symbol | String)?) -> void
592
701
 
593
702
  # Adds a chart to the current worksheet.
594
703
  #
@@ -609,8 +718,8 @@ module Xlsxrb
609
718
  # @param location [String, nil] Internal location.
610
719
  # @return [void]
611
720
  # @api public
612
- # : (String | Integer cell, ?String? url, ?display: String?, ?tooltip: String?, ?location: String?) -> void
613
- def hyperlink: (String | Integer cell, ?String? url, ?display: String?, ?tooltip: String?, ?location: String?) -> void
721
+ # : (String | Integer cell, ?(String | Elements::Hyperlink)? url, ?display: String?, ?tooltip: String?, ?location: String?) -> void
722
+ def hyperlink: (String | Integer cell, ?(String | Elements::Hyperlink)? url, ?display: String?, ?tooltip: String?, ?location: String?) -> void
614
723
 
615
724
  # Sets the auto-filter range on the active sheet.
616
725
  #
@@ -641,12 +750,13 @@ module Xlsxrb
641
750
 
642
751
  # Adds a data validation rule.
643
752
  #
644
- # @param sqref [String] Cell range.
753
+ # @param sqref [String, nil] Cell range.
645
754
  # @param opts [Hash] Validation options.
755
+ # @yield [data_validation_builder] Optional configuration block.
646
756
  # @return [void]
647
757
  # @api public
648
- # : (untyped sqref, **untyped opts) -> void
649
- def validate_data: (untyped sqref, **untyped opts) -> void
758
+ # : (?String? sqref, **untyped opts) ?{ (DataValidationBuilder) -> void } -> void
759
+ def validate_data: (?String? sqref, **untyped opts) ?{ (DataValidationBuilder) -> void } -> void
650
760
 
651
761
  # Adds a conditional formatting rule.
652
762
  #
@@ -659,16 +769,17 @@ module Xlsxrb
659
769
 
660
770
  # Adds an Excel Table (ListObject).
661
771
  #
662
- # @param ref [String] Table range.
663
- # @param columns [Array<String>] Column names.
772
+ # @param ref [String, nil] Table range.
773
+ # @param columns [Array<String>, nil] Column names.
664
774
  # @param name [String, nil] Table name.
665
775
  # @param display_name [String, nil] Display name.
666
776
  # @param style [String, nil] Table style.
667
777
  # @param opts [Hash] Additional options.
778
+ # @yield [table_builder] Optional configuration block.
668
779
  # @return [void]
669
780
  # @api public
670
- # : (untyped ref, columns: untyped, ?name: untyped, ?display_name: untyped, ?style: untyped, **untyped opts) -> void
671
- def table: (untyped ref, columns: untyped, ?name: untyped, ?display_name: untyped, ?style: untyped, **untyped opts) -> void
781
+ # : (?String? ref, ?columns: untyped, ?name: untyped, ?display_name: untyped, ?style: untyped, **untyped opts) ?{ (TableBuilder) -> void } -> void
782
+ def table: (?String? ref, ?columns: untyped, ?name: untyped, ?display_name: untyped, ?style: untyped, **untyped opts) ?{ (TableBuilder) -> void } -> void
672
783
 
673
784
  # Adds a Pivot Table.
674
785
  #
@@ -706,6 +817,26 @@ module Xlsxrb
706
817
  # : (sparklines: untyped, ?type: untyped, **untyped opts) -> void
707
818
  def sparkline_group: (sparklines: untyped, ?type: untyped, **untyped opts) -> void
708
819
 
820
+ # Adds a single sparkline to the sheet.
821
+ #
822
+ # @example Add a line sparkline
823
+ # writer.add_sparkline(location: "F1", range: "A1:E1")
824
+ #
825
+ # @example Add a column sparkline with high/low markers
826
+ # writer.add_sparkline(location: "F2", range: "A2:E2", type: :column, high: true, low: true)
827
+ #
828
+ # @example Add a win/loss sparkline
829
+ # writer.add_sparkline(location: "F3", range: "A3:E3", type: :win_loss)
830
+ #
831
+ # @param location [String, nil] Target cell for the sparkline (e.g. "F1").
832
+ # @param range [String, nil] Data range for the sparkline (e.g. "A1:E1").
833
+ # @param type [Symbol, String, nil] Sparkline type (:line, :column, :win_loss / :stacked).
834
+ # @param opts [Hash] Additional sparkline options.
835
+ # @return [void]
836
+ # @api public
837
+ # : (?location: String?, ?range: String?, ?type: (String | Symbol)?, **untyped opts) -> void
838
+ def add_sparkline: (?location: String?, ?range: String?, ?type: (String | Symbol)?, **untyped opts) -> void
839
+
709
840
  # Merges a range of cells into a single cell.
710
841
  #
711
842
  # @param range [String, Hash, nil] Cell range (e.g. "A1:B2") or hash of coordinates.
@@ -840,6 +971,16 @@ module Xlsxrb
840
971
  # : (Symbol name, untyped value) -> void
841
972
  def sheet_view: (Symbol name, untyped value) -> void
842
973
 
974
+ # Configures sheet format properties (e.g. default_row_height, default_col_width).
975
+ #
976
+ # @param name [Symbol, String, Hash, nil] Property name or hash of properties.
977
+ # @param value [Object, nil] Property value when name is provided.
978
+ # @param opts [Hash] Keyword arguments for sheet format properties.
979
+ # @return [Hash[Symbol, untyped]]
980
+ # @api public
981
+ # : (?Symbol | String | Hash[Symbol, untyped] | nil name, ?untyped value, **untyped opts) -> Hash[Symbol, untyped]
982
+ def sheet_format: (?Symbol | String | Hash[Symbol, untyped] | nil name, ?untyped value, **untyped opts) -> Hash[Symbol, untyped]
983
+
843
984
  # Inserts a horizontal page break before a row.
844
985
  #
845
986
  # @param row_num [Integer] 1-based row number.
@@ -856,6 +997,29 @@ module Xlsxrb
856
997
  # : (Integer col_index) -> void
857
998
  def page_break_col: (Integer col_index) -> void
858
999
 
1000
+ # Adds a protected range to the current sheet.
1001
+ #
1002
+ # @param name [String] Name of the protected range.
1003
+ # @param sqref [String] Cell range (e.g. "A1:B10").
1004
+ # @param password [String, nil] Optional password or hash.
1005
+ # @param opts [Hash] Additional options.
1006
+ # @return [void]
1007
+ # @api public
1008
+ # : (String name, String sqref, ?password: String?, **untyped opts) -> void
1009
+ def protected_range: (String name, String sqref, ?password: String?, **untyped opts) -> void
1010
+
1011
+ alias add_protected_range protected_range
1012
+
1013
+ # Adds a cell watch to the current sheet.
1014
+ #
1015
+ # @param ref [String] Cell reference (e.g. "A1").
1016
+ # @return [void]
1017
+ # @api public
1018
+ # : (String ref) -> void
1019
+ def cell_watch: (String ref) -> void
1020
+
1021
+ alias add_cell_watch cell_watch
1022
+
859
1023
  # Adds a defined name.
860
1024
  #
861
1025
  # @param name [String] The defined name.
@@ -886,6 +1050,32 @@ module Xlsxrb
886
1050
  # : (?rows: String?, ?cols: String?, ?sheet: String?) -> void
887
1051
  def print_titles: (?rows: String?, ?cols: String?, ?sheet: String?) -> void
888
1052
 
1053
+ # Sets repeating title rows for pagination on the current or named sheet.
1054
+ #
1055
+ # @example Repeat first row
1056
+ # stream.repeat_rows(0)
1057
+ #
1058
+ # @param first [Integer, String] First row index (0-based) or range string (e.g. "1:2").
1059
+ # @param last [Integer, String, nil] Optional last row index (0-based).
1060
+ # @param sheet [String, nil] Target sheet name.
1061
+ # @return [void]
1062
+ # @api public
1063
+ # : (Integer | String first, ?(Integer | String)? last, ?sheet: String?) -> void
1064
+ def repeat_rows: (Integer | String first, ?(Integer | String)? last, ?sheet: String?) -> void
1065
+
1066
+ # Sets repeating title columns for pagination on the current or named sheet.
1067
+ #
1068
+ # @example Repeat columns A through C
1069
+ # stream.repeat_columns("A", "C")
1070
+ #
1071
+ # @param first [Integer, String] First column index (0-based) or column name/range.
1072
+ # @param last [Integer, String, nil] Optional last column index/name.
1073
+ # @param sheet [String, nil] Target sheet name.
1074
+ # @return [void]
1075
+ # @api public
1076
+ # : (Integer | String first, ?(Integer | String)? last, ?sheet: String?) -> void
1077
+ def repeat_columns: (Integer | String first, ?(Integer | String)? last, ?sheet: String?) -> void
1078
+
889
1079
  # Sets workbook protection.
890
1080
  #
891
1081
  # @param opts [Hash] Protection options.
@@ -7,6 +7,43 @@ module Xlsxrb
7
7
  class StyleBuilder
8
8
  COLORS: untyped
9
9
 
10
+ CSS_COLORS: untyped
11
+
12
+ BORDER_STYLES: untyped
13
+
14
+ BORDER_INDEX_MAP: untyped
15
+
16
+ # Normalizes a color definition (CSS color name, hex code, or RGB integer) to an OpenXML hex color string.
17
+ #
18
+ # @example
19
+ # StyleBuilder.normalize_color(:navy) #=> "FF000080"
20
+ # StyleBuilder.normalize_color("#FF0000") #=> "FFFF0000"
21
+ # StyleBuilder.normalize_color("#F00") #=> "FFFF0000"
22
+ # StyleBuilder.normalize_color("FF0000", alpha: false) #=> "FF0000"
23
+ # StyleBuilder.normalize_color(0xFF0000) #=> "FFFF0000"
24
+ #
25
+ # @param color [String, Symbol, Integer, nil]
26
+ # @param alpha [Boolean] Whether to include the alpha channel ("AARRGGBB" vs "RRGGBB").
27
+ # @return [String, nil]
28
+ # @api public
29
+ # : (String | Symbol | Integer | nil color, ?alpha: bool) -> String?
30
+ def self.normalize_color: (String | Symbol | Integer | nil color, ?alpha: bool) -> String?
31
+
32
+ # Normalizes a border style symbol, string, or integer index to an OOXML ST_BorderStyle symbol.
33
+ #
34
+ # @example
35
+ # StyleBuilder.normalize_border_style(:border_thin) #=> :thin
36
+ # StyleBuilder.normalize_border_style(1) #=> :thin
37
+ # StyleBuilder.normalize_border_style(:medium_dashed) #=> :mediumDashed
38
+ # StyleBuilder.normalize_border_style("double") #=> :double
39
+ # StyleBuilder.normalize_border_style(0) #=> :none
40
+ #
41
+ # @param style [Symbol, String, Integer, nil]
42
+ # @return [Symbol, nil]
43
+ # @api public
44
+ # : (Symbol | String | Integer | nil style) -> Symbol?
45
+ def self.normalize_border_style: (Symbol | String | Integer | nil style) -> Symbol?
46
+
10
47
  # Resolves a color symbol, string, or prefix to an aRGB hex string.
11
48
  #
12
49
  # @param color [Symbol, String, Object, nil]
@@ -147,55 +184,55 @@ module Xlsxrb
147
184
  def border: (**untyped) -> self
148
185
 
149
186
  # Sets all borders.
150
- # @param style [String, Symbol] The border style.
187
+ # @param style [String, Symbol, Integer] The border style.
151
188
  # @param color [String, Symbol, nil] The color.
152
189
  # @return [self]
153
190
  # @api public
154
- # : (?style: String | Symbol, ?color: String | Symbol | nil) -> self
155
- def border_all: (?style: String | Symbol, ?color: String | Symbol | nil) -> self
191
+ # : (?style: String | Symbol | Integer, ?color: String | Symbol | nil) -> self
192
+ def border_all: (?style: String | Symbol | Integer, ?color: String | Symbol | nil) -> self
156
193
 
157
194
  # Sets the left border.
158
- # @param style [String, Symbol] The border style.
195
+ # @param style [String, Symbol, Integer] The border style.
159
196
  # @param color [String, Symbol, nil] The color.
160
197
  # @return [self]
161
198
  # @api public
162
- # : (?style: String | Symbol, ?color: String | Symbol | nil) -> self
163
- def border_left: (?style: String | Symbol, ?color: String | Symbol | nil) -> self
199
+ # : (?style: String | Symbol | Integer, ?color: String | Symbol | nil) -> self
200
+ def border_left: (?style: String | Symbol | Integer, ?color: String | Symbol | nil) -> self
164
201
 
165
202
  # Sets the right border.
166
- # @param style [String, Symbol] The border style.
203
+ # @param style [String, Symbol, Integer] The border style.
167
204
  # @param color [String, Symbol, nil] The color.
168
205
  # @return [self]
169
206
  # @api public
170
- # : (?style: String | Symbol, ?color: String | Symbol | nil) -> self
171
- def border_right: (?style: String | Symbol, ?color: String | Symbol | nil) -> self
207
+ # : (?style: String | Symbol | Integer, ?color: String | Symbol | nil) -> self
208
+ def border_right: (?style: String | Symbol | Integer, ?color: String | Symbol | nil) -> self
172
209
 
173
210
  # Sets the top border.
174
- # @param style [String, Symbol] The border style.
211
+ # @param style [String, Symbol, Integer] The border style.
175
212
  # @param color [String, Symbol, nil] The color.
176
213
  # @return [self]
177
214
  # @api public
178
- # : (?style: String | Symbol, ?color: String | Symbol | nil) -> self
179
- def border_top: (?style: String | Symbol, ?color: String | Symbol | nil) -> self
215
+ # : (?style: String | Symbol | Integer, ?color: String | Symbol | nil) -> self
216
+ def border_top: (?style: String | Symbol | Integer, ?color: String | Symbol | nil) -> self
180
217
 
181
218
  # Sets the bottom border.
182
- # @param style [String, Symbol] The border style.
219
+ # @param style [String, Symbol, Integer] The border style.
183
220
  # @param color [String, Symbol, nil] The color.
184
221
  # @return [self]
185
222
  # @api public
186
- # : (?style: String | Symbol, ?color: String | Symbol | nil) -> self
187
- def border_bottom: (?style: String | Symbol, ?color: String | Symbol | nil) -> self
223
+ # : (?style: String | Symbol | Integer, ?color: String | Symbol | nil) -> self
224
+ def border_bottom: (?style: String | Symbol | Integer, ?color: String | Symbol | nil) -> self
188
225
 
189
226
  # rubocop:disable Naming/MethodParameterName
190
227
  # Sets diagonal borders.
191
- # @param style [String, Symbol] The border style.
228
+ # @param style [String, Symbol, Integer] The border style.
192
229
  # @param color [String, Symbol, nil] The color.
193
230
  # @param up [Boolean] Diagonal up.
194
231
  # @param down [Boolean] Diagonal down.
195
232
  # @return [self]
196
233
  # @api public
197
- # : (?style: String | Symbol, ?color: String | Symbol | nil, ?up: bool, ?down: bool) -> self
198
- def border_diagonal: (?style: String | Symbol, ?color: String | Symbol | nil, ?up: bool, ?down: bool) -> self
234
+ # : (?style: String | Symbol | Integer, ?color: String | Symbol | nil, ?up: bool, ?down: bool) -> self
235
+ def border_diagonal: (?style: String | Symbol | Integer, ?color: String | Symbol | nil, ?up: bool, ?down: bool) -> self
199
236
 
200
237
  # Sets horizontal alignment.
201
238
  # @param value [String, Symbol] The alignment.
@@ -0,0 +1,151 @@
1
+ # Generated from lib/xlsxrb/utils.rb with RBS::Inline
2
+
3
+ module Xlsxrb
4
+ # Public coordinate conversion and reference parsing utilities.
5
+ #
6
+ # @api public
7
+ module Utils
8
+ # Converts a cell reference string (e.g. "A1", "BC100") to 0-based [row, col] coordinates.
9
+ #
10
+ # @example
11
+ # Xlsxrb::Utils.ref_to_row_col("A1") #=> [0, 0]
12
+ # Xlsxrb::Utils.ref_to_row_col("BC100") #=> [99, 54]
13
+ #
14
+ # @param cell_ref [String, nil] Excel cell reference string.
15
+ # @return [Array(Integer, Integer), nil] 0-based [row_idx, col_idx] tuple, or nil if invalid.
16
+ # @api public
17
+ # : (String? cell_ref) -> [Integer, Integer]?
18
+ def self.ref_to_row_col: (String? cell_ref) -> [ Integer, Integer ]?
19
+
20
+ # Converts 0-based [row_idx, col_idx] coordinates to an A1-style reference string.
21
+ #
22
+ # @example
23
+ # Xlsxrb::Utils.row_col_to_ref(0, 0) #=> "A1"
24
+ # Xlsxrb::Utils.row_col_to_ref(99, 54) #=> "BC100"
25
+ #
26
+ # @param row_idx [Integer] 0-based row index.
27
+ # @param col_idx [Integer] 0-based column index.
28
+ # @return [String] A1-style reference string.
29
+ # @api public
30
+ # : (Integer row_idx, Integer col_idx) -> String
31
+ def self.row_col_to_ref: (Integer row_idx, Integer col_idx) -> String
32
+
33
+ # Converts a cell range reference string (e.g. "A1:C10", "B2:D5", "A1") to 0-based
34
+ # [[top_row, left_col], [bottom_row, right_col]] coordinate pairs.
35
+ #
36
+ # @example Range reference
37
+ # Xlsxrb::Utils.parse_range("A1:C10") #=> [[0, 0], [9, 2]]
38
+ #
39
+ # @example Single cell reference
40
+ # Xlsxrb::Utils.parse_range("B5") #=> [[4, 1], [4, 1]]
41
+ #
42
+ # @param range_ref [String, nil] Cell range reference string.
43
+ # @return [Array([Integer, Integer], [Integer, Integer]), nil] 0-based coordinate pairs, or nil if invalid.
44
+ # @api public
45
+ # : (String? range_ref) -> [[Integer, Integer], [Integer, Integer]]?
46
+ def self.parse_range: (String? range_ref) -> [ [ Integer, Integer ], [ Integer, Integer ] ]?
47
+
48
+ # Converts 0-based bounding coordinates to an A1-style range reference string.
49
+ #
50
+ # @example Range coordinates
51
+ # Xlsxrb::Utils.range_to_ref(0, 0, 9, 2) #=> "A1:C10"
52
+ #
53
+ # @example Single cell coordinates
54
+ # Xlsxrb::Utils.range_to_ref(4, 1, 4, 1) #=> "B5"
55
+ #
56
+ # @param top_row [Integer] 0-based start row index.
57
+ # @param left_col [Integer] 0-based start column index.
58
+ # @param bottom_row [Integer] 0-based end row index.
59
+ # @param right_col [Integer] 0-based end column index.
60
+ # @return [String] A1-style range reference string.
61
+ # @api public
62
+ # : (Integer top_row, Integer left_col, Integer bottom_row, Integer right_col) -> String
63
+ def self.range_to_ref: (Integer top_row, Integer left_col, Integer bottom_row, Integer right_col) -> String
64
+
65
+ # Converts a column letter name (e.g. "A", "BC") to a 0-based integer index.
66
+ #
67
+ # @example
68
+ # Xlsxrb::Utils.col_name_to_index("A") #=> 0
69
+ # Xlsxrb::Utils.col_name_to_index("BC") #=> 54
70
+ #
71
+ # @param col_name [String, Symbol, Integer] Column letter or index.
72
+ # @return [Integer] 0-based column index.
73
+ # @api public
74
+ # : (String | Symbol | Integer col_name) -> Integer
75
+ def self.col_name_to_index: (String | Symbol | Integer col_name) -> Integer
76
+
77
+ # Converts a 0-based column integer index to a column letter name (e.g. 0 -> "A", 54 -> "BC").
78
+ #
79
+ # @example
80
+ # Xlsxrb::Utils.col_index_to_name(0) #=> "A"
81
+ # Xlsxrb::Utils.col_index_to_name(54) #=> "BC"
82
+ #
83
+ # @param col_idx [Integer] 0-based column index.
84
+ # @return [String] Column letter name.
85
+ # @api public
86
+ # : (Integer col_idx) -> String
87
+ def self.col_index_to_name: (Integer col_idx) -> String
88
+
89
+ # Splits an A1-style cell reference into its column name and 1-based row number.
90
+ #
91
+ # @example
92
+ # Xlsxrb::Utils.split_coordinate("A1") #=> ["A", 1]
93
+ # Xlsxrb::Utils.split_coordinate("BC100") #=> ["BC", 100]
94
+ #
95
+ # @param cell_ref [String, nil] Excel cell reference string.
96
+ # @return [Array(String, Integer), nil] [col_name, row_number] tuple (1-based row), or nil if invalid.
97
+ # @api public
98
+ # : (String? cell_ref) -> [String, Integer]?
99
+ def self.split_coordinate: (String? cell_ref) -> [ String, Integer ]?
100
+
101
+ # Converts a Date or Time to an Excel numeric serial number (1900 or 1904 system).
102
+ #
103
+ # @example
104
+ # Xlsxrb::Utils.date_to_serial(Date.new(2026, 1, 1)) #=> 46023
105
+ #
106
+ # @param date_or_time [Date, Time] Date or Time instance.
107
+ # @param date1904 [Boolean] Whether to use the 1904 date system.
108
+ # @return [Integer, Float] Serial number.
109
+ # @api public
110
+ # : (Date | Time date_or_time, ?date1904: bool) -> (Integer | Float)
111
+ def self.date_to_serial: (Date | Time date_or_time, ?date1904: bool) -> (Integer | Float)
112
+
113
+ # Converts an Excel serial number to a Date.
114
+ #
115
+ # @example
116
+ # Xlsxrb::Utils.serial_to_date(46023) #=> #<Date: 2026-01-01>
117
+ #
118
+ # @param serial [Numeric] Excel serial number.
119
+ # @param date1904 [Boolean] Whether to use the 1904 date system.
120
+ # @return [Date]
121
+ # @api public
122
+ # : (Numeric serial, ?date1904: bool) -> Date
123
+ def self.serial_to_date: (Numeric serial, ?date1904: bool) -> Date
124
+
125
+ # Converts a Time or Date to a fractional Excel serial number.
126
+ #
127
+ # @example
128
+ # Xlsxrb::Utils.datetime_to_serial(Time.utc(2026, 1, 1, 12, 0, 0)) #=> 46023.5
129
+ #
130
+ # @param time [Time, Date] Time or Date instance.
131
+ # @param date1904 [Boolean] Whether to use the 1904 date system.
132
+ # @return [Float] Fractional serial number.
133
+ # @api public
134
+ # : (Time | Date time, ?date1904: bool) -> Float
135
+ def self.datetime_to_serial: (Time | Date time, ?date1904: bool) -> Float
136
+
137
+ # Converts an Excel serial number to a Time (UTC).
138
+ #
139
+ # @example
140
+ # Xlsxrb::Utils.serial_to_time(46023.5) #=> 2026-01-01 12:00:00 UTC
141
+ #
142
+ # @param serial [Numeric] Excel serial number.
143
+ # @param date1904 [Boolean] Whether to use the 1904 date system.
144
+ # @return [Time]
145
+ # @api public
146
+ # : (Numeric serial, ?date1904: bool) -> Time
147
+ def self.serial_to_time: (Numeric serial, ?date1904: bool) -> Time
148
+
149
+ alias self.serial_to_datetime self.serial_to_time
150
+ end
151
+ end