xlsxrb 0.1.17 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +256 -1
  3. data/README.md +111 -28
  4. data/lib/ruby_lsp/xlsxrb/completion_listener.rb +439 -139
  5. data/lib/xlsxrb/chart_builder.rb +540 -193
  6. data/lib/xlsxrb/dsl_helpers.rb +178 -73
  7. data/lib/xlsxrb/elements/cell.rb +197 -130
  8. data/lib/xlsxrb/elements/column.rb +88 -7
  9. data/lib/xlsxrb/elements/coordinate_access.rb +86 -59
  10. data/lib/xlsxrb/elements/image.rb +18 -19
  11. data/lib/xlsxrb/elements/metadata.rb +2379 -0
  12. data/lib/xlsxrb/elements/row.rb +84 -118
  13. data/lib/xlsxrb/elements/styles.rb +140 -90
  14. data/lib/xlsxrb/elements/types.rb +164 -22
  15. data/lib/xlsxrb/elements/workbook.rb +122 -140
  16. data/lib/xlsxrb/elements/worksheet.rb +451 -226
  17. data/lib/xlsxrb/elements.rb +1 -0
  18. data/lib/xlsxrb/ooxml/reader/listeners/core_listeners.rb +16 -5
  19. data/lib/xlsxrb/ooxml/reader/listeners/drawing_listeners.rb +14 -9
  20. data/lib/xlsxrb/ooxml/reader/listeners/feature_listeners.rb +296 -34
  21. data/lib/xlsxrb/ooxml/reader/listeners/style_listeners.rb +17 -3
  22. data/lib/xlsxrb/ooxml/reader.rb +52 -50
  23. data/lib/xlsxrb/ooxml/styles_parser.rb +36 -5
  24. data/lib/xlsxrb/ooxml/utils.rb +2 -2
  25. data/lib/xlsxrb/ooxml/workbook_parser.rb +0 -1
  26. data/lib/xlsxrb/ooxml/workbook_writer.rb +242 -109
  27. data/lib/xlsxrb/ooxml/worksheet_parser.rb +63 -31
  28. data/lib/xlsxrb/ooxml/worksheet_writer.rb +119 -56
  29. data/lib/xlsxrb/ooxml/writer/drawing_xml.rb +33 -13
  30. data/lib/xlsxrb/ooxml/writer/features_xml.rb +75 -15
  31. data/lib/xlsxrb/ooxml/writer/styles_xml.rb +18 -8
  32. data/lib/xlsxrb/ooxml/writer.rb +124 -44
  33. data/lib/xlsxrb/ooxml/xml_parser.rb +78 -5
  34. data/lib/xlsxrb/ooxml/zip_generator.rb +2 -0
  35. data/lib/xlsxrb/ooxml/zip_reader.rb +112 -25
  36. data/lib/xlsxrb/ooxml/zip_writer.rb +119 -30
  37. data/lib/xlsxrb/stream_row.rb +56 -81
  38. data/lib/xlsxrb/stream_sheet.rb +542 -273
  39. data/lib/xlsxrb/stream_writer.rb +1536 -870
  40. data/lib/xlsxrb/style_builder.rb +667 -221
  41. data/lib/xlsxrb/version.rb +1 -1
  42. data/lib/xlsxrb/workbook_builder.rb +406 -143
  43. data/lib/xlsxrb/worksheet_builder.rb +1009 -900
  44. data/lib/xlsxrb.rb +1179 -1056
  45. data/sig/generated/xlsxrb/chart_builder.rbs +385 -159
  46. data/sig/generated/xlsxrb/dsl_helpers.rbs +81 -15
  47. data/sig/generated/xlsxrb/elements/cell.rbs +78 -70
  48. data/sig/generated/xlsxrb/elements/column.rbs +55 -3
  49. data/sig/generated/xlsxrb/elements/coordinate_access.rbs +35 -29
  50. data/sig/generated/xlsxrb/elements/image.rbs +7 -11
  51. data/sig/generated/xlsxrb/elements/metadata.rbs +1574 -0
  52. data/sig/generated/xlsxrb/elements/row.rbs +39 -42
  53. data/sig/generated/xlsxrb/elements/styles.rbs +66 -66
  54. data/sig/generated/xlsxrb/elements/types.rbs +27 -0
  55. data/sig/generated/xlsxrb/elements/workbook.rbs +46 -99
  56. data/sig/generated/xlsxrb/elements/worksheet.rbs +121 -96
  57. data/sig/generated/xlsxrb/ooxml/reader/listeners/feature_listeners.rbs +61 -4
  58. data/sig/generated/xlsxrb/ooxml/reader.rbs +2 -2
  59. data/sig/generated/xlsxrb/ooxml/styles_parser.rbs +1 -1
  60. data/sig/generated/xlsxrb/ooxml/utils.rbs +3 -3
  61. data/sig/generated/xlsxrb/ooxml/workbook_writer.rbs +13 -1
  62. data/sig/generated/xlsxrb/ooxml/worksheet_parser.rbs +16 -0
  63. data/sig/generated/xlsxrb/ooxml/worksheet_writer.rbs +6 -4
  64. data/sig/generated/xlsxrb/ooxml/writer/features_xml.rbs +7 -0
  65. data/sig/generated/xlsxrb/ooxml/writer.rbs +22 -13
  66. data/sig/generated/xlsxrb/ooxml/xml_parser.rbs +70 -0
  67. data/sig/generated/xlsxrb/ooxml/zip_generator.rbs +2 -0
  68. data/sig/generated/xlsxrb/ooxml/zip_reader.rbs +24 -9
  69. data/sig/generated/xlsxrb/ooxml/zip_writer.rbs +26 -1
  70. data/sig/generated/xlsxrb/stream_row.rbs +32 -33
  71. data/sig/generated/xlsxrb/stream_sheet.rbs +233 -181
  72. data/sig/generated/xlsxrb/stream_writer.rbs +961 -667
  73. data/sig/generated/xlsxrb/style_builder.rbs +402 -128
  74. data/sig/generated/xlsxrb/workbook_builder.rbs +223 -71
  75. data/sig/generated/xlsxrb/worksheet_builder.rbs +579 -453
  76. data/sig/generated/xlsxrb.rbs +205 -144
  77. data/sig/rexml.rbs +8 -0
  78. metadata +5 -5
  79. data/lib/xlsxrb/utils.rb +0 -291
  80. data/sig/generated/xlsxrb/utils.rbs +0 -184
@@ -13,107 +13,169 @@ module Xlsxrb
13
13
  #
14
14
  # @api public
15
15
  class Worksheet
16
+ # @return [Array<Hash[Symbol, untyped]>]
17
+ #
18
+ # Corresponds to ECMA-376 Part 4 §18.3.1.18 (<conditionalFormatting> and <cfRule> elements).
19
+ # In the OpenXML specification, conditional formatting definitions are emitted as
20
+ # `<conditionalFormatting>` elements containing individual rule definitions (`<cfRule>`).
21
+ # While ECMA-376 uses the uncountable noun `conditionalFormatting` as the XML element name,
22
+ # xlsxrb exposes these rules collectively as {#conditional_formats} (Array of Hashes)
23
+ # to maintain symmetric plural collection naming alongside other collections
24
+ # (e.g. {#tables}, {#data_validations}, {#merged_cells}) and paired with the singular builder
25
+ # method {WorksheetBuilder#conditional_format}.
26
+ #
27
+ # @api public
28
+ # : Array[Elements::ConditionalFormat]
29
+ attr_reader conditional_formats: untyped
30
+
31
+ # : String?
16
32
  attr_reader name: untyped
17
33
 
34
+ # : Array[Elements::Row]
18
35
  attr_reader rows: untyped
19
36
 
37
+ # : Array[Elements::Column]
20
38
  attr_reader columns: untyped
21
39
 
40
+ # : Array[Elements::Chart]
22
41
  attr_reader charts: untyped
23
42
 
24
- attr_reader conditional_formatting: untyped
25
-
43
+ # : Array[Elements::DataValidation]
26
44
  attr_reader data_validations: untyped
27
45
 
46
+ # : Hash[untyped, untyped]
28
47
  attr_reader unmapped_data: untyped
29
48
 
49
+ # : Array[String]
30
50
  attr_reader errors: untyped
31
51
 
52
+ # : Symbol
32
53
  attr_reader state: untyped
33
54
 
55
+ # : Hash[String, Elements::Hyperlink]
34
56
  attr_reader hyperlinks: untyped
35
57
 
58
+ # : Array[Elements::Comment]
36
59
  attr_reader comments: untyped
37
60
 
61
+ # : Array[Elements::Image]
38
62
  attr_reader images: untyped
39
63
 
64
+ # : (Elements::Styles | Hash[untyped, untyped])?
40
65
  attr_reader styles: untyped
41
66
 
42
- attr_reader date1904: untyped
43
-
67
+ # : String?
44
68
  attr_reader print_area: untyped
45
69
 
70
+ # : Elements::PrintTitles?
46
71
  attr_reader print_titles: untyped
47
72
 
73
+ # : Array[Elements::SparklineGroup]
48
74
  attr_reader sparkline_groups: untyped
49
75
 
76
+ # : Array[String]
50
77
  attr_reader merged_cells: untyped
51
78
 
79
+ # : String?
52
80
  attr_reader auto_filter: untyped
53
81
 
82
+ # : Array[Elements::Table]
54
83
  attr_reader tables: untyped
55
84
 
85
+ # : Array[Elements::Shape]
56
86
  attr_reader shapes: untyped
57
87
 
88
+ # : Elements::FreezePane?
58
89
  attr_reader freeze_pane: untyped
59
90
 
91
+ # : Elements::PageSetup
60
92
  attr_reader page_setup: untyped
61
93
 
94
+ # : Elements::PageMargins?
62
95
  attr_reader page_margins: untyped
63
96
 
97
+ # : Elements::HeaderFooter
64
98
  attr_reader header_footer: untyped
65
99
 
100
+ # : Elements::PrintOptions
66
101
  attr_reader print_options: untyped
67
102
 
103
+ # : Elements::SheetProtection?
68
104
  attr_reader sheet_protection: untyped
69
105
 
106
+ # : Elements::SheetView
70
107
  attr_reader sheet_view: untyped
71
108
 
109
+ # : Elements::SheetProperties
72
110
  attr_reader sheet_properties: untyped
73
111
 
112
+ # : Elements::SheetFormat
74
113
  attr_reader sheet_format: untyped
75
114
 
115
+ # : Array[Elements::PageBreak]
76
116
  attr_reader row_breaks: untyped
77
117
 
78
- attr_reader col_breaks: untyped
118
+ # : Array[Elements::PageBreak]
119
+ attr_reader column_breaks: untyped
79
120
 
121
+ # : Array[Elements::ProtectedRange]
80
122
  attr_reader protected_ranges: untyped
81
123
 
124
+ # : Array[String]
82
125
  attr_reader cell_watches: untyped
83
126
 
127
+ # : Array[Elements::IgnoredError]
84
128
  attr_reader ignored_errors: untyped
85
129
 
130
+ # : Elements::PhoneticProperties?
86
131
  attr_reader phonetic_properties: untyped
87
132
 
133
+ # : (Elements::Selection | Array[Elements::Selection])?
88
134
  attr_reader selection: untyped
89
135
 
90
- attr_reader sheet_calc_pr: untyped
91
-
136
+ # : Elements::BackgroundImage?
92
137
  attr_reader background_image: untyped
93
138
 
139
+ # : Array[Elements::ThreadedComment]
94
140
  attr_reader threaded_comments: untyped
95
141
 
96
- attr_writer dimension: untyped
142
+ # : Array[Elements::PivotTable]
143
+ attr_reader pivot_tables: untyped
97
144
 
98
- alias conditional_formats conditional_formatting
145
+ # : Elements::SplitPane?
146
+ attr_reader split_pane: untyped
99
147
 
100
- alias phonetic_pr phonetic_properties
148
+ # : Hash[Integer, Elements::FilterColumn]
149
+ attr_reader filter_columns: untyped
101
150
 
102
- alias calc_pr sheet_calc_pr
151
+ # : Elements::SortState?
152
+ attr_reader sort_state: untyped
103
153
 
104
- alias background_picture background_image
154
+ # : Array[Elements::HeaderFooterImage]
155
+ attr_reader header_footer_images: untyped
105
156
 
106
- alias picture background_image
157
+ # Support array pattern matching.
158
+ #
159
+ # @return [Array<Object>]
160
+ # @api public
161
+ # : () -> Array[untyped]
162
+ def deconstruct: () -> Array[untyped]
163
+
164
+ # Returns worksheet calculation properties (<sheetCalcPr>), or nil if none configured.
165
+ #
166
+ # @return [Elements::SheetCalcProperties, nil]
167
+ # @api public
168
+ # : () -> Elements::SheetCalcProperties?
169
+ def sheet_calc_properties: () -> Elements::SheetCalcProperties?
107
170
 
108
171
  # @param name [String] The worksheet name (max 31 characters).
109
172
  # @param rows [Array<Elements::Row>] Rows in the sheet.
110
173
  # @param columns [Array<Elements::Column>] Column definitions.
111
174
  # @param charts [Array<Hash>] Charts in the sheet.
112
- # @param conditional_formatting [Array<Hash>, nil] Conditional formatting rules.
175
+ # @param conditional_formats [Array<Hash, Elements::ConditionalFormat>] Conditional formatting rules.
113
176
  # @param data_validations [Array<Hash>] Data validation rules.
114
177
  # @param unmapped_data [Hash] Additional metadata for round-tripping.
115
178
  # @param errors [Array<String>, nil] Validation errors.
116
- # @param conditional_formats [Array<Hash>, nil] Alias for conditional_formatting.
117
179
  # @param state [Symbol] Sheet visibility state (:visible, :hidden, or :very_hidden).
118
180
  # @param hyperlinks [Hash{String => Hash}] Hyperlink mappings by cell reference.
119
181
  # @param comments [Array<Hash>] Comments and notes in the sheet.
@@ -140,17 +202,17 @@ module Xlsxrb
140
202
  # @param sheet_properties [Hash] Sheet properties (e.g. tabColor, outlinePr).
141
203
  # @param sheet_format [Hash] Sheet format properties (e.g. defaultRowHeight, defaultColWidth).
142
204
  # @param row_breaks [Array<Integer | Hash>] Explicit page row breaks.
143
- # @param col_breaks [Array<Integer | Hash>] Explicit page column breaks.
205
+ # @param column_breaks [Array<Integer | Hash>] Explicit page column breaks.
144
206
  # @param protected_ranges [Array<Hash>] Protected range definitions.
145
207
  # @param cell_watches [Array<String>] Watched cell references.
146
208
  # @param ignored_errors [Array<Hash>] Ignored error rules.
147
209
  # @param phonetic_properties [Hash, nil] Phonetic text properties.
148
210
  # @param selection [Hash, Array<Hash>, nil] Active cell and selection settings.
149
- # @param sheet_calc_pr [Hash, nil] Worksheet calculation properties.
211
+ # @param sheet_calc_properties [Hash, nil] Worksheet calculation properties.
150
212
  # @param background_image [Hash, nil] Worksheet background image specification.
151
213
  # @param threaded_comments [Array<Hash>] Threaded comments in the sheet.
152
- # : (name: String?, ?rows: Array[Elements::Row], ?columns: Array[Elements::Column], ?charts: Array[Hash[Symbol, untyped]], ?conditional_formatting: Array[Hash[Symbol, untyped]]?, ?data_validations: Array[Hash[Symbol, untyped]], ?unmapped_data: Hash[untyped, untyped], ?errors: Array[String]?, ?conditional_formats: Array[Hash[Symbol, untyped]]?, ?state: Symbol, ?hyperlinks: Hash[String, untyped], ?comments: Array[Hash[Symbol, untyped]], ?images: Array[Elements::Image], ?styles: (Elements::Styles | Hash[untyped, untyped])?, ?date1904: bool, ?dimension: String?, ?trim_empty_rows: bool, ?pad_empty_rows: bool, ?pad_empty_cells: bool, ?print_area: String?, ?print_titles: Hash[Symbol, untyped]?, ?sparkline_groups: Array[Hash[Symbol, untyped]], ?merged_cells: Array[String], ?auto_filter: String?, ?tables: Array[Hash[Symbol, untyped]], ?shapes: Array[Hash[Symbol, untyped]], ?freeze_pane: Hash[Symbol, untyped]?, ?page_setup: Hash[Symbol, untyped], ?page_margins: Hash[Symbol, untyped]?, ?header_footer: Hash[Symbol, untyped], ?print_options: Hash[Symbol, untyped], ?sheet_protection: Hash[Symbol, untyped]?, ?sheet_view: Hash[Symbol, untyped], ?sheet_properties: Hash[Symbol, untyped], ?sheet_format: Hash[Symbol, untyped], ?row_breaks: Array[untyped], ?col_breaks: Array[untyped], ?protected_ranges: Array[Hash[Symbol, untyped]], ?cell_watches: Array[String], ?ignored_errors: Array[Hash[Symbol, untyped]], ?phonetic_properties: Hash[Symbol, untyped]?, ?selection: (Hash[Symbol, untyped] | Array[Hash[Symbol, untyped]])?, ?sheet_calc_pr: Hash[Symbol, untyped]?, ?background_image: Hash[Symbol, untyped]?, ?threaded_comments: Array[Hash[Symbol, untyped]]) -> void
153
- def initialize: (name: String?, ?rows: Array[Elements::Row], ?columns: Array[Elements::Column], ?charts: Array[Hash[Symbol, untyped]], ?conditional_formatting: Array[Hash[Symbol, untyped]]?, ?data_validations: Array[Hash[Symbol, untyped]], ?unmapped_data: Hash[untyped, untyped], ?errors: Array[String]?, ?conditional_formats: Array[Hash[Symbol, untyped]]?, ?state: Symbol, ?hyperlinks: Hash[String, untyped], ?comments: Array[Hash[Symbol, untyped]], ?images: Array[Elements::Image], ?styles: (Elements::Styles | Hash[untyped, untyped])?, ?date1904: bool, ?dimension: String?, ?trim_empty_rows: bool, ?pad_empty_rows: bool, ?pad_empty_cells: bool, ?print_area: String?, ?print_titles: Hash[Symbol, untyped]?, ?sparkline_groups: Array[Hash[Symbol, untyped]], ?merged_cells: Array[String], ?auto_filter: String?, ?tables: Array[Hash[Symbol, untyped]], ?shapes: Array[Hash[Symbol, untyped]], ?freeze_pane: Hash[Symbol, untyped]?, ?page_setup: Hash[Symbol, untyped], ?page_margins: Hash[Symbol, untyped]?, ?header_footer: Hash[Symbol, untyped], ?print_options: Hash[Symbol, untyped], ?sheet_protection: Hash[Symbol, untyped]?, ?sheet_view: Hash[Symbol, untyped], ?sheet_properties: Hash[Symbol, untyped], ?sheet_format: Hash[Symbol, untyped], ?row_breaks: Array[untyped], ?col_breaks: Array[untyped], ?protected_ranges: Array[Hash[Symbol, untyped]], ?cell_watches: Array[String], ?ignored_errors: Array[Hash[Symbol, untyped]], ?phonetic_properties: Hash[Symbol, untyped]?, ?selection: (Hash[Symbol, untyped] | Array[Hash[Symbol, untyped]])?, ?sheet_calc_pr: Hash[Symbol, untyped]?, ?background_image: Hash[Symbol, untyped]?, ?threaded_comments: Array[Hash[Symbol, untyped]]) -> void
214
+ # : (name: String?, ?rows: Array[Elements::Row], ?columns: Array[Elements::Column], ?charts: Array[untyped], ?data_validations: Array[untyped], ?unmapped_data: Hash[untyped, untyped], ?errors: Array[String]?, ?conditional_formats: Array[untyped]?, ?state: Symbol, ?hyperlinks: Hash[String, untyped], ?comments: Array[untyped], ?images: Array[Elements::Image], ?styles: (Elements::Styles | Hash[untyped, untyped])?, ?date1904: bool, ?dimension: String?, ?trim_empty_rows: bool, ?pad_empty_rows: bool, ?pad_empty_cells: bool, ?print_area: String?, ?print_titles: untyped, ?sparkline_groups: Array[untyped], ?merged_cells: Array[String], ?auto_filter: String?, ?tables: Array[untyped], ?shapes: Array[untyped], ?freeze_pane: untyped, ?page_setup: untyped, ?page_margins: untyped, ?header_footer: untyped, ?print_options: untyped, ?sheet_protection: untyped, ?sheet_view: untyped, ?sheet_properties: untyped, ?sheet_format: untyped, ?row_breaks: Array[untyped], ?column_breaks: Array[untyped]?, ?protected_ranges: Array[untyped], ?cell_watches: Array[String], ?ignored_errors: Array[untyped], ?phonetic_properties: untyped, ?selection: untyped, ?sheet_calc_properties: untyped, ?background_image: untyped, ?threaded_comments: Array[untyped], ?pivot_tables: Array[untyped]?, ?split_pane: untyped, ?filter_columns: Hash[Integer, untyped]?, ?sort_state: untyped, ?header_footer_images: Array[untyped]?) -> void
215
+ def initialize: (name: String?, ?rows: Array[Elements::Row], ?columns: Array[Elements::Column], ?charts: Array[untyped], ?data_validations: Array[untyped], ?unmapped_data: Hash[untyped, untyped], ?errors: Array[String]?, ?conditional_formats: Array[untyped]?, ?state: Symbol, ?hyperlinks: Hash[String, untyped], ?comments: Array[untyped], ?images: Array[Elements::Image], ?styles: (Elements::Styles | Hash[untyped, untyped])?, ?date1904: bool, ?dimension: String?, ?trim_empty_rows: bool, ?pad_empty_rows: bool, ?pad_empty_cells: bool, ?print_area: String?, ?print_titles: untyped, ?sparkline_groups: Array[untyped], ?merged_cells: Array[String], ?auto_filter: String?, ?tables: Array[untyped], ?shapes: Array[untyped], ?freeze_pane: untyped, ?page_setup: untyped, ?page_margins: untyped, ?header_footer: untyped, ?print_options: untyped, ?sheet_protection: untyped, ?sheet_view: untyped, ?sheet_properties: untyped, ?sheet_format: untyped, ?row_breaks: Array[untyped], ?column_breaks: Array[untyped]?, ?protected_ranges: Array[untyped], ?cell_watches: Array[String], ?ignored_errors: Array[untyped], ?phonetic_properties: untyped, ?selection: untyped, ?sheet_calc_properties: untyped, ?background_image: untyped, ?threaded_comments: Array[untyped], ?pivot_tables: Array[untyped]?, ?split_pane: untyped, ?filter_columns: Hash[Integer, untyped]?, ?sort_state: untyped, ?header_footer_images: Array[untyped]?) -> void
154
216
 
155
217
  # Returns whether trailing empty rows are omitted during iteration.
156
218
  #
@@ -159,17 +221,13 @@ module Xlsxrb
159
221
  # : () -> bool
160
222
  def trim_empty_rows?: () -> bool
161
223
 
162
- alias trim_empty_rows trim_empty_rows?
163
-
164
- # Returns whether skipped rows are padded during iteration.
224
+ # Returns whether empty rows are yielded for skipped row numbers during iteration.
165
225
  #
166
226
  # @return [Boolean]
167
227
  # @api public
168
228
  # : () -> bool
169
229
  def pad_empty_rows?: () -> bool
170
230
 
171
- alias pad_empty_rows pad_empty_rows?
172
-
173
231
  # Returns whether missing cells within rows are padded during iteration.
174
232
  #
175
233
  # @return [Boolean]
@@ -177,8 +235,6 @@ module Xlsxrb
177
235
  # : () -> bool
178
236
  def pad_empty_cells?: () -> bool
179
237
 
180
- alias pad_empty_cells pad_empty_cells?
181
-
182
238
  # Returns whether the worksheet uses the 1904 date system.
183
239
  #
184
240
  # @return [Boolean]
@@ -215,8 +271,6 @@ module Xlsxrb
215
271
  # : () -> bool
216
272
  def fit_to_page?: () -> bool
217
273
 
218
- alias fit_to_page fit_to_page?
219
-
220
274
  # Returns whether full calculation on load is enabled on this worksheet.
221
275
  #
222
276
  # @return [Boolean]
@@ -224,8 +278,6 @@ module Xlsxrb
224
278
  # : () -> bool
225
279
  def full_calc_on_load?: () -> bool
226
280
 
227
- alias full_calc_on_load full_calc_on_load?
228
-
229
281
  # Returns the outline and grouping properties of the worksheet, or an empty hash if none configured.
230
282
  #
231
283
  # @return [Hash]
@@ -233,8 +285,6 @@ module Xlsxrb
233
285
  # : () -> Hash[Symbol, untyped]
234
286
  def outline_properties: () -> Hash[Symbol, untyped]
235
287
 
236
- alias outline_pr outline_properties
237
-
238
288
  # Iterate over rows in the worksheet.
239
289
  #
240
290
  # @example
@@ -327,22 +377,11 @@ module Xlsxrb
327
377
  # Returns all images anchored at a specific cell reference or 0-based coordinate.
328
378
  #
329
379
  # @param ref_or_row [String, Symbol, Integer] Cell reference (e.g. "A1") or 0-based row index.
330
- # @param col [Integer, nil] Optional 0-based column index.
380
+ # @param col [Integer, String, Symbol, nil] Optional 0-based column index or column letter/Symbol.
331
381
  # @return [Array<Elements::Image>]
332
382
  # @api public
333
- # : (String | Symbol | Integer ref_or_row, ?Integer? col) -> Array[Elements::Image]
334
- def images_at: (String | Symbol | Integer ref_or_row, ?Integer? col) -> Array[Elements::Image]
335
-
336
- # Yields self with images loaded or returns self.
337
- #
338
- # @yield [sheet]
339
- # @yieldparam sheet [Elements::Worksheet]
340
- # @return [Elements::Worksheet, void]
341
- # @api public
342
- # : () { (Elements::Worksheet) -> void } -> void
343
- # : () -> Elements::Worksheet
344
- def with_images: () { (Elements::Worksheet) -> void } -> void
345
- | () -> Elements::Worksheet
383
+ # : (String | Symbol | Integer ref_or_row, ?Integer | String | Symbol | nil col) -> Array[Elements::Image]
384
+ def images_at: (String | Symbol | Integer ref_or_row, ?Integer | String | Symbol | nil col) -> Array[Elements::Image]
346
385
 
347
386
  # Returns whether the worksheet is valid according to OOXML specifications.
348
387
  #
@@ -374,77 +413,67 @@ module Xlsxrb
374
413
  # Returns hyperlink metadata for the given cell reference, or nil.
375
414
  #
376
415
  # @param ref_or_row [String, Symbol, Integer] Cell reference (e.g. "A1") or 0-based row index.
377
- # @param col [Integer, nil] Optional 0-based column index if ref_or_row is a row index.
378
- # @return [Hash, nil]
416
+ # @param col [Integer, String, Symbol, nil] Optional 0-based column index or column letter/Symbol.
417
+ # @return [Elements::Hyperlink, nil]
379
418
  # @api public
380
- # : (String | Symbol | Integer ref_or_row, ?Integer? col) -> Hash[Symbol, untyped]?
381
- def hyperlink: (String | Symbol | Integer ref_or_row, ?Integer? col) -> Hash[Symbol, untyped]?
419
+ # : (String | Symbol | Integer | nil ref_or_row, ?Integer | String | Symbol | nil col) -> Elements::Hyperlink?
420
+ def hyperlink: (String | Symbol | Integer | nil ref_or_row, ?Integer | String | Symbol | nil col) -> Elements::Hyperlink?
382
421
 
383
422
  # Returns comment metadata for the given cell reference, or nil.
384
423
  #
385
424
  # @param ref_or_row [String, Symbol, Integer] Cell reference (e.g. "A1") or 0-based row index.
386
- # @param col [Integer, nil] Optional 0-based column index if ref_or_row is a row index.
387
- # @return [Hash, nil]
425
+ # @param col [Integer, String, Symbol, nil] Optional 0-based column index or column letter/Symbol.
426
+ # @return [Elements::Comment, nil]
388
427
  # @api public
389
- # : (String | Symbol | Integer ref_or_row, ?Integer? col) -> Hash[Symbol, untyped]?
390
- def comment: (String | Symbol | Integer ref_or_row, ?Integer? col) -> Hash[Symbol, untyped]?
428
+ # : (String | Symbol | Integer | nil ref_or_row, ?Integer | String | Symbol | nil col) -> Elements::Comment?
429
+ def comment: (String | Symbol | Integer | nil ref_or_row, ?Integer | String | Symbol | nil col) -> Elements::Comment?
391
430
 
392
431
  # Returns comments indexed by cell reference.
393
432
  #
394
- # @return [Hash<String, Hash[Symbol, untyped]>]
433
+ # @return [Hash<String, Elements::Comment>]
395
434
  # @api public
396
- # : () -> Hash[String, Hash[Symbol, untyped]]
397
- def comments_by_ref: () -> Hash[String, Hash[Symbol, untyped]]
435
+ # : () -> Hash[String, Elements::Comment]
436
+ def comments_by_ref: () -> Hash[String, Elements::Comment]
437
+
438
+ # Returns the root threaded comment for the given cell reference, or nil.
439
+ #
440
+ # @param ref_or_row [String, Symbol, Integer] Cell reference (e.g. "A1") or 0-based row index.
441
+ # @param col [Integer, String, Symbol, nil] Optional 0-based column index or column letter/Symbol.
442
+ # @return [Elements::ThreadedComment, nil]
443
+ # @api public
444
+ # : (String | Symbol | Integer ref_or_row, ?Integer | String | Symbol | nil col) -> Elements::ThreadedComment?
445
+ def threaded_comment: (String | Symbol | Integer ref_or_row, ?Integer | String | Symbol | nil col) -> Elements::ThreadedComment?
398
446
 
399
447
  # Returns threaded comments for the given cell reference, or empty array.
400
448
  #
401
449
  # @param ref_or_row [String, Symbol, Integer] Cell reference (e.g. "A1") or 0-based row index.
402
- # @param col [Integer, nil] Optional 0-based column index.
403
- # @return [Array<Hash[Symbol, untyped]>]
450
+ # @param col [Integer, String, Symbol, nil] Optional 0-based column index or column letter/Symbol.
451
+ # @return [Array<Elements::ThreadedComment>]
404
452
  # @api public
405
- # : (String | Symbol | Integer ref_or_row, ?Integer? col) -> Array[Hash[Symbol, untyped]]
406
- def threaded_comment: (String | Symbol | Integer ref_or_row, ?Integer? col) -> Array[Hash[Symbol, untyped]]
453
+ # : (String | Symbol | Integer ref_or_row, ?Integer | String | Symbol | nil col) -> Array[Elements::ThreadedComment]
454
+ def threaded_comments_at: (String | Symbol | Integer ref_or_row, ?Integer | String | Symbol | nil col) -> Array[Elements::ThreadedComment]
407
455
 
408
456
  # Returns threaded comments indexed by cell reference.
409
457
  #
410
- # @return [Hash<String, Array<Hash[Symbol, untyped]>>]
458
+ # @return [Hash<String, Array<Elements::ThreadedComment>>]
411
459
  # @api public
412
- # : () -> Hash[String, Array[Hash[Symbol, untyped]]]
413
- def threaded_comments_by_ref: () -> Hash[String, Array[Hash[Symbol, untyped]]]
460
+ # : () -> Hash[String, Array[Elements::ThreadedComment]]
461
+ def threaded_comments_by_ref: () -> Hash[String, Array[Elements::ThreadedComment]]
414
462
 
415
463
  # Access a cell by reference or 0-based coordinates.
416
464
  #
417
465
  # @param ref_or_row [String, Symbol, Integer] Cell reference (e.g. "A1") or 0-based row index.
418
- # @param col [Integer, nil] Optional 0-based column index.
466
+ # @param col [Integer, String, Symbol, nil] Optional 0-based column index or column letter/Symbol.
419
467
  # @return [Elements::Cell, nil]
420
468
  # @api public
421
- # : (String | Symbol | Integer ref_or_row, ?Integer? col) -> Elements::Cell?
422
- def cell: (String | Symbol | Integer ref_or_row, ?Integer? col) -> Elements::Cell?
423
-
424
469
  # Returns the formatted string representation of a cell's value.
425
470
  #
426
471
  # @param ref_or_row [String, Symbol, Integer] Cell reference (e.g. "A1") or 0-based row index.
427
- # @param col [Integer, nil] Optional 0-based column index.
472
+ # @param col [Integer, String, Symbol, nil] Optional 0-based column index or column letter/Symbol.
428
473
  # @return [String, nil]
429
474
  # @api public
430
- # : (String | Symbol | Integer ref_or_row, ?Integer? col) -> String?
431
- def formatted_value: (String | Symbol | Integer ref_or_row, ?Integer? col) -> String?
432
-
433
- # Returns a new Worksheet with the specified cell updated.
434
- #
435
- # @example
436
- # new_sheet = sheet.update_cell("B1", value: "Updated")
437
- #
438
- # @param ref [String] The cell reference (e.g. "B1").
439
- # @param value [Object] The new cell value.
440
- # @param style_index [Integer, String, nil] Optional new style index.
441
- # @param formula [Elements::Formula, nil] Optional new formula.
442
- # @param hyperlink [Hash, String, nil] Optional new hyperlink.
443
- # @param comment [Hash, String, nil] Optional new comment.
444
- # @return [Worksheet] A new Worksheet instance.
445
- # @api public
446
- # : (String ref, ?value: untyped, ?style_index: Integer | String | nil, ?formula: Elements::Formula?, ?hyperlink: (Hash[Symbol, untyped] | String)?, ?comment: (Hash[Symbol, untyped] | String)?) -> Elements::Worksheet
447
- def update_cell: (String ref, ?value: untyped, ?style_index: Integer | String | nil, ?formula: Elements::Formula?, ?hyperlink: (Hash[Symbol, untyped] | String)?, ?comment: (Hash[Symbol, untyped] | String)?) -> Elements::Worksheet
475
+ # : (String | Symbol | Integer ref_or_row, ?Integer | String | Symbol | nil col) -> String?
476
+ def formatted_value: (String | Symbol | Integer ref_or_row, ?Integer | String | Symbol | nil col) -> String?
448
477
 
449
478
  # Returns a new Worksheet with attributes replaced (Data-like behavior).
450
479
  #
@@ -467,17 +496,12 @@ module Xlsxrb
467
496
  # : () -> Integer
468
497
  def hash: () -> Integer
469
498
 
470
- # Returns self when load is called on an already in-memory Worksheet.
471
- #
472
- # @return [Elements::Worksheet]
473
- # @api public
474
- # : () -> Elements::Worksheet
475
- def load: () -> Elements::Worksheet
476
-
477
- alias to_worksheet load
478
-
479
499
  FORBIDDEN_NAME_CHARS: ::Regexp
480
500
 
501
+ # @api private
502
+ # : () -> Regexp
503
+ def self.forbidden_name_chars: () -> Regexp
504
+
481
505
  # Returns whether the worksheet name is valid according to OOXML specifications (1..31 chars, no forbidden chars).
482
506
  #
483
507
  # @param name [Object]
@@ -490,6 +514,7 @@ module Xlsxrb
490
514
  # @param name [String]
491
515
  # @param rows [Array<Elements::Row>]
492
516
  # @return [Array<String>] List of errors.
517
+ # @api private
493
518
  # : (untyped name, untyped rows) -> Array[String]
494
519
  def self.validate: (untyped name, untyped rows) -> Array[String]
495
520
 
@@ -274,8 +274,6 @@ module Xlsxrb
274
274
  private
275
275
 
276
276
  def element_name: (untyped local_name, untyped qname) -> untyped
277
-
278
- def xml_unescape: (untyped str) -> untyped
279
277
  end
280
278
 
281
279
  # SAX2 listener for parsing conditionalFormatting elements.
@@ -317,6 +315,8 @@ module Xlsxrb
317
315
 
318
316
  attr_reader col_breaks: untyped
319
317
 
318
+ attr_reader column_breaks: untyped
319
+
320
320
  def initialize: () -> untyped
321
321
 
322
322
  def start_element: (untyped _uri, untyped local_name, untyped qname, untyped attributes) -> untyped
@@ -400,8 +400,6 @@ module Xlsxrb
400
400
  private
401
401
 
402
402
  def element_name: (untyped local_name, untyped qname) -> untyped
403
-
404
- def xml_unescape: (untyped str) -> untyped
405
403
  end
406
404
 
407
405
  # SAX2 listener for parsing pivotCacheRecords XML.
@@ -473,6 +471,65 @@ module Xlsxrb
473
471
 
474
472
  def element_name: (untyped local_name, untyped qname) -> untyped
475
473
  end
474
+
475
+ # SAX2 listener for parsing <x14:sparklineGroups> and child <x14:sparklineGroup> elements.
476
+ class SparklineGroupsListener
477
+ include REXML::SAX2Listener
478
+
479
+ COLOR_TAG_MAP: untyped
480
+
481
+ # @return [Array<Hash[Symbol, untyped]>]
482
+ # : Array[Hash[Symbol, untyped]]
483
+ attr_reader groups: untyped
484
+
485
+ alias sparkline_groups groups
486
+
487
+ # : () -> void
488
+ def initialize: () -> void
489
+
490
+ # : (untyped _uri, String? local_name, String? qname, Hash[String, String] attributes) -> void
491
+ def start_element: (untyped _uri, String? local_name, String? qname, Hash[String, String] attributes) -> void
492
+
493
+ # : (String text) -> void
494
+ def characters: (String text) -> void
495
+
496
+ # : (untyped _uri, String? local_name, String? qname) -> void
497
+ def end_element: (untyped _uri, String? local_name, String? qname) -> void
498
+
499
+ private
500
+
501
+ # : (String? str) -> (Integer | Float | nil)
502
+ def parse_numeric: (String? str) -> (Integer | Float | nil)
503
+
504
+ # : (Hash[String, String] attributes) -> (String | Hash[Symbol, untyped] | nil)
505
+ def parse_color: (Hash[String, String] attributes) -> (String | Hash[Symbol, untyped] | nil)
506
+
507
+ # : (String? local_name, String? qname) -> String
508
+ def element_name: (String? local_name, String? qname) -> String
509
+ end
510
+
511
+ # SAX2 listener for parsing VML drawings of header and footer images (<v:shape> and <v:imagedata>).
512
+ class VmlHeaderFooterListener
513
+ include REXML::SAX2Listener
514
+
515
+ # @return [Array<Hash[Symbol, untyped]>]
516
+ # : Array[Hash[Symbol, untyped]]
517
+ attr_reader shapes: untyped
518
+
519
+ # : () -> void
520
+ def initialize: () -> void
521
+
522
+ # : (untyped _uri, String? local_name, String? qname, Hash[String, String] attributes) -> void
523
+ def start_element: (untyped _uri, String? local_name, String? qname, Hash[String, String] attributes) -> void
524
+
525
+ # : (untyped _uri, String? local_name, String? qname) -> void
526
+ def end_element: (untyped _uri, String? local_name, String? qname) -> void
527
+
528
+ private
529
+
530
+ # : (String? local_name, String? qname) -> String
531
+ def element_name: (String? local_name, String? qname) -> String
532
+ end
476
533
  end
477
534
  end
478
535
  end
@@ -3,6 +3,8 @@
3
3
  module Xlsxrb
4
4
  module Ooxml
5
5
  # Reads cells from an XLSX file.
6
+ #
7
+ # @api private
6
8
  class Reader
7
9
  def initialize: (untyped filepath) -> untyped
8
10
 
@@ -95,8 +97,6 @@ module Xlsxrb
95
97
  # Returns outline and grouping properties (<outlinePr>) for the given sheet.
96
98
  def outline_properties: (?sheet: untyped) -> untyped
97
99
 
98
- alias outline_pr outline_properties
99
-
100
100
  # Returns phonetic properties for the given sheet, or nil if not present.
101
101
  def phonetic_properties: (?sheet: untyped) -> untyped
102
102
 
@@ -3,7 +3,7 @@
3
3
  module Xlsxrb
4
4
  module Ooxml
5
5
  # SAX-based parser for xl/styles.xml.
6
- # Returns an Elements::Styles (Hash) with :num_fmts, :fonts, :fills, :borders, :cell_xfs, :cell_style_xfs.
6
+ # Returns an Elements::Styles (Hash) with :num_fmts, :fonts, :fills, :borders, :cell_xfs, :cell_style_xfs, :cell_styles.
7
7
  class StylesParser
8
8
  # : (String? xml_string) -> Elements::Styles
9
9
  def self.parse: (String? xml_string) -> Elements::Styles
@@ -46,9 +46,9 @@ module Xlsxrb
46
46
  # : (Numeric serial, ?date1904: bool) -> Date
47
47
  def self.serial_to_date: (Numeric serial, ?date1904: bool) -> Date
48
48
 
49
- # Converts a Time to a fractional Excel serial number (1900 or 1904 system).
50
- # : (Time time, ?date1904: bool) -> Float
51
- def self.datetime_to_serial: (Time time, ?date1904: bool) -> Float
49
+ # Converts a Time or DateTime to a fractional Excel serial number (1900 or 1904 system).
50
+ # : (Time | DateTime time, ?date1904: bool) -> Float
51
+ def self.datetime_to_serial: (Time | DateTime time, ?date1904: bool) -> Float
52
52
 
53
53
  # Converts a fractional Excel serial number to a Time (1900 or 1904 system, UTC).
54
54
  # Excel serial numbers carry no timezone metadata; returned Time objects are in UTC.
@@ -38,6 +38,14 @@ module Xlsxrb
38
38
 
39
39
  private
40
40
 
41
+ PIVOT_CACHE_OPTIONS: untyped
42
+
43
+ # Returns the source and keyword arguments of Writer#add_pivot_table for a pivot table hash,
44
+ # as the builders create it or as Xlsxrb.load reads it (with the source, field names, and
45
+ # shared items in :cache, and pivot field attributes in :fields).
46
+ # : (Hash[Symbol, untyped] pivot_table) -> [String?, Hash[Symbol, untyped]]
47
+ def pivot_table_arguments: (Hash[Symbol, untyped] pivot_table) -> [ String?, Hash[Symbol, untyped] ]
48
+
41
49
  def build_sheet_rels_from_list: (untyped rels) -> untyped
42
50
 
43
51
  def build_content_types: () -> untyped
@@ -54,6 +62,10 @@ module Xlsxrb
54
62
 
55
63
  def extract_dxf_from_rule!: (untyped rule) -> untyped
56
64
 
65
+ # Writes one <xf> of cellXfs, or of cellStyleXfs when style_xf_count is nil. An xfId that
66
+ # points past the written cellStyleXfs is dropped, so it falls back to the first entry.
67
+ def write_xf: (untyped builder, untyped format, style_xf_count: untyped) -> untyped
68
+
57
69
  def write_dxf_font: (untyped builder, untyped font) -> untyped
58
70
 
59
71
  def write_dxf_fill: (untyped builder, untyped fill) -> untyped
@@ -80,7 +92,7 @@ module Xlsxrb
80
92
 
81
93
  def write_shared_strings_xml: (untyped zip) -> untyped
82
94
 
83
- def write_worksheet_xml: (untyped io, untyped sheet, ?drawing_rid: untyped, ?picture_rid: untyped, ?sheet_protection: untyped, ?protected_ranges: untyped, ?auto_filter: untyped, ?filter_columns: untyped, ?sort_state: untyped, ?merge_cells: untyped, ?conditional_formats: untyped, ?data_validations: untyped, ?hyperlinks: untyped, ?print_options: untyped, ?page_margins: untyped, ?page_setup: untyped, ?header_footer: untyped, ?row_breaks: untyped, ?col_breaks: untyped, ?cell_watches: untyped, ?ignored_errors: untyped, ?freeze_pane: untyped, ?split_pane: untyped, ?selection: untyped, ?sheet_view: untyped, ?sheet_properties: untyped, ?sheet_format: untyped, ?tables: untyped, ?table_start_rid: untyped, ?legacy_drawing_rid: untyped, ?sparkline_groups: untyped, ?phonetic_pr: untyped, ?sheet_calc_pr: untyped) -> untyped
95
+ def write_worksheet_xml: (untyped io, untyped sheet, ?drawing_rid: untyped, ?picture_rid: untyped, ?sheet_protection: untyped, ?protected_ranges: untyped, ?auto_filter: untyped, ?filter_columns: untyped, ?sort_state: untyped, ?merge_cells: untyped, ?conditional_formats: untyped, ?data_validations: untyped, ?hyperlinks: untyped, ?print_options: untyped, ?page_margins: untyped, ?page_setup: untyped, ?header_footer: untyped, ?row_breaks: untyped, ?col_breaks: untyped, ?column_breaks: untyped, ?cell_watches: untyped, ?ignored_errors: untyped, ?freeze_pane: untyped, ?split_pane: untyped, ?selection: untyped, ?sheet_view: untyped, ?sheet_properties: untyped, ?sheet_format: untyped, ?tables: untyped, ?table_start_rid: untyped, ?legacy_drawing_rid: untyped, ?sparkline_groups: untyped, ?phonetic_pr: untyped, ?sheet_calc_pr: untyped) -> untyped
84
96
 
85
97
  def build_table_xml: (untyped tbl, untyped table_id) -> untyped
86
98
 
@@ -45,12 +45,25 @@ module Xlsxrb
45
45
  # Extract an attribute value from a small tag substring (bounded search).
46
46
  def self.tag_attr: (untyped tag, untyped prefix) -> untyped
47
47
 
48
+ # Like tag_attr, with entity references such as &amp; and &quot; decoded.
49
+ def self.decoded_attr: (untyped tag, untyped prefix) -> untyped
50
+
48
51
  def self.fast_scan_cells_events: (untyped xml, untyped from, untyped to, untyped shared_strings, untyped row_source, ?untyped prefix, ?untyped shared_masters) ?{ (?) -> untyped } -> untyped
49
52
 
50
53
  def self.extract_inline_text: (untyped xml, untyped from, untyped to) -> untyped
51
54
 
52
55
  STRICT_NUMERIC_RE: ::Regexp
53
56
 
57
+ # Returns str without leading and trailing whitespace, allocating a new String only
58
+ # when there is whitespace to remove (cell values rarely have any).
59
+ # : (String str) -> String
60
+ def self.strip_ws: (String str) -> String
61
+
62
+ # Retags a String captured from the binary scan buffer as UTF-8 in place, without
63
+ # copying. Only for Strings the caller has just created (e.g. regex captures).
64
+ # : (String? str) -> String?
65
+ def self.utf8!: (String? str) -> String?
66
+
54
67
  # Resolves a cell value from its type attribute and parsed XML content (<v> or <is>).
55
68
  # Consolidates parsing across fast-scan direct, row values, events, and listener paths.
56
69
  # : (String? type, String? raw_value, String? is_xml, Array[String | Elements::RichText | untyped] shared_strings) -> untyped
@@ -99,6 +112,9 @@ module Xlsxrb
99
112
 
100
113
  COL_MAP: untyped
101
114
 
115
+ # Captures r, s, and t directly when they appear in the order Excel and xlsxrb write them
116
+ # (groups 1 to 3). Any other attribute set or order falls back to capturing the raw
117
+ # attribute string (group 4, or group 8 for a self-closing cell) for ATTR_* lookups.
102
118
  CELL_FAST_RE: ::Regexp
103
119
 
104
120
  CELL_GENERIC_RE: ::Regexp