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
@@ -21,18 +21,152 @@ module Xlsxrb
21
21
 
22
22
  attr_reader charts: untyped
23
23
 
24
+ attr_reader conditional_formatting: untyped
25
+
26
+ attr_reader data_validations: untyped
27
+
24
28
  attr_reader unmapped_data: untyped
25
29
 
26
30
  attr_reader errors: untyped
27
31
 
32
+ attr_reader state: untyped
33
+
34
+ attr_reader hyperlinks: untyped
35
+
36
+ attr_reader comments: untyped
37
+
38
+ attr_reader images: untyped
39
+
40
+ attr_reader styles: untyped
41
+
42
+ attr_reader date1904: untyped
43
+
44
+ attr_reader print_area: untyped
45
+
46
+ attr_reader print_titles: untyped
47
+
48
+ attr_reader sparkline_groups: untyped
49
+
50
+ attr_reader merged_cells: untyped
51
+
52
+ attr_reader auto_filter: untyped
53
+
54
+ attr_reader tables: untyped
55
+
56
+ attr_reader shapes: untyped
57
+
58
+ attr_reader freeze_pane: untyped
59
+
60
+ attr_reader page_setup: untyped
61
+
62
+ attr_reader page_margins: untyped
63
+
64
+ attr_reader header_footer: untyped
65
+
66
+ attr_reader print_options: untyped
67
+
68
+ attr_reader sheet_protection: untyped
69
+
70
+ attr_reader sheet_view: untyped
71
+
72
+ attr_reader sheet_properties: untyped
73
+
74
+ attr_reader sheet_format: untyped
75
+
76
+ attr_reader row_breaks: untyped
77
+
78
+ attr_reader col_breaks: untyped
79
+
80
+ attr_reader protected_ranges: untyped
81
+
82
+ attr_reader cell_watches: untyped
83
+
84
+ attr_writer dimension: untyped
85
+
86
+ alias conditional_formats conditional_formatting
87
+
28
88
  # @param name [String] The worksheet name (max 31 characters).
29
89
  # @param rows [Array<Elements::Row>] Rows in the sheet.
30
90
  # @param columns [Array<Elements::Column>] Column definitions.
31
91
  # @param charts [Array<Hash>] Charts in the sheet.
92
+ # @param conditional_formatting [Array<Hash>, nil] Conditional formatting rules.
93
+ # @param data_validations [Array<Hash>] Data validation rules.
32
94
  # @param unmapped_data [Hash] Additional metadata for round-tripping.
33
95
  # @param errors [Array<String>, nil] Validation errors.
34
- # : (name: String?, ?rows: Array[Elements::Row], ?columns: Array[Elements::Column], ?charts: Array[Hash[Symbol, untyped]], ?unmapped_data: Hash[untyped, untyped], ?errors: Array[String]?) -> void
35
- def initialize: (name: String?, ?rows: Array[Elements::Row], ?columns: Array[Elements::Column], ?charts: Array[Hash[Symbol, untyped]], ?unmapped_data: Hash[untyped, untyped], ?errors: Array[String]?) -> void
96
+ # @param conditional_formats [Array<Hash>, nil] Alias for conditional_formatting.
97
+ # @param state [Symbol] Sheet visibility state (:visible, :hidden, or :very_hidden).
98
+ # @param hyperlinks [Hash{String => Hash}] Hyperlink mappings by cell reference.
99
+ # @param comments [Array<Hash>] Comments and notes in the sheet.
100
+ # @param images [Array<Elements::Image>] Embedded images in the sheet.
101
+ # @param styles [Hash, nil] Optional parsed styles hash.
102
+ # @param dimension [String, nil] Sheet dimension reference string (e.g. "A1:Z50000").
103
+ # @param trim_empty_rows [Boolean] Whether to omit trailing empty rows during iteration.
104
+ # @param pad_empty_rows [Boolean] Whether to yield empty rows for skipped row numbers.
105
+ # @param pad_empty_cells [Boolean] Whether to pad missing cells within rows.
106
+ # @param print_area [String, nil] Sheet print area range (e.g. "A1:H50").
107
+ # @param print_titles [Hash, nil] Repeating print title rows/cols (e.g. { rows: "1:2", cols: "A:B" }).
108
+ # @param sparkline_groups [Array<Hash>] Sparkline groups in the sheet.
109
+ # @param merged_cells [Array<String>] Merged cell ranges (e.g. ["A1:B2"]).
110
+ # @param auto_filter [String, nil] AutoFilter range (e.g. "A1:E10").
111
+ # @param tables [Array<Hash>] Table definitions in the sheet.
112
+ # @param shapes [Array<Hash>] Shape definitions in the sheet.
113
+ # @param freeze_pane [Hash, nil] Freeze pane settings (e.g. { row: 1, col: 0 }).
114
+ # @param page_setup [Hash] Page setup properties (e.g. orientation, paper size).
115
+ # @param page_margins [Hash, nil] Page margins settings.
116
+ # @param header_footer [Hash] Header and footer configurations.
117
+ # @param print_options [Hash] Print options (e.g. gridlines, headings).
118
+ # @param sheet_protection [Hash, nil] Sheet protection settings.
119
+ # @param sheet_view [Hash] Sheet view configurations (e.g. zoom, gridlines).
120
+ # @param sheet_properties [Hash] Sheet properties (e.g. tabColor, outlinePr).
121
+ # @param sheet_format [Hash] Sheet format properties (e.g. defaultRowHeight, defaultColWidth).
122
+ # @param row_breaks [Array<Integer | Hash>] Explicit page row breaks.
123
+ # @param col_breaks [Array<Integer | Hash>] Explicit page column breaks.
124
+ # @param protected_ranges [Array<Hash>] Protected range definitions.
125
+ # @param cell_watches [Array<String>] Watched cell references.
126
+ # : (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: 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]) -> void
127
+ 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: 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]) -> void
128
+
129
+ # Returns whether trailing empty rows are omitted during iteration.
130
+ #
131
+ # @return [Boolean]
132
+ # @api public
133
+ # : () -> bool
134
+ def trim_empty_rows?: () -> bool
135
+
136
+ alias trim_empty_rows trim_empty_rows?
137
+
138
+ # Returns whether skipped rows are padded during iteration.
139
+ #
140
+ # @return [Boolean]
141
+ # @api public
142
+ # : () -> bool
143
+ def pad_empty_rows?: () -> bool
144
+
145
+ alias pad_empty_rows pad_empty_rows?
146
+
147
+ # Returns whether missing cells within rows are padded during iteration.
148
+ #
149
+ # @return [Boolean]
150
+ # @api public
151
+ # : () -> bool
152
+ def pad_empty_cells?: () -> bool
153
+
154
+ alias pad_empty_cells pad_empty_cells?
155
+
156
+ # Returns whether the worksheet uses the 1904 date system.
157
+ #
158
+ # @return [Boolean]
159
+ # @api public
160
+ # : () -> bool
161
+ def date1904?: () -> bool
162
+
163
+ # Returns the worksheet dimension reference string (e.g. "A1:Z50000"),
164
+ # or computes it dynamically from rows if not explicitly set.
165
+ #
166
+ # @return [String, nil]
167
+ # @api public
168
+ # : () -> String?
169
+ def dimension: () -> String?
36
170
 
37
171
  # Iterate over rows in the worksheet.
38
172
  #
@@ -41,14 +175,25 @@ module Xlsxrb
41
175
  # puts row.to_a.inspect
42
176
  # end
43
177
  #
44
- # @yield [row]
45
- # @yieldparam row [Elements::Row]
46
- # @return [Enumerator, void]
178
+ # @overload each(trim_empty_rows: nil, pad_empty_rows: nil, pad_empty_cells: nil, &block)
179
+ # @param trim_empty_rows [Boolean, nil] Whether to omit trailing empty rows.
180
+ # @param pad_empty_rows [Boolean, nil] Whether to yield empty rows for skipped row numbers.
181
+ # @param pad_empty_cells [Boolean, nil] Whether to pad missing cells within rows.
182
+ # @yield [row]
183
+ # @yieldparam row [Elements::Row]
184
+ # @return [void]
185
+ #
186
+ # @overload each(trim_empty_rows: nil, pad_empty_rows: nil, pad_empty_cells: nil)
187
+ # @param trim_empty_rows [Boolean, nil] Whether to omit trailing empty rows.
188
+ # @param pad_empty_rows [Boolean, nil] Whether to yield empty rows for skipped row numbers.
189
+ # @param pad_empty_cells [Boolean, nil] Whether to pad missing cells within rows.
190
+ # @return [Enumerator<Elements::Row, void>]
191
+ #
47
192
  # @api public
48
- # : () { (Elements::Row) -> void } -> void
49
- # : () -> Enumerator[Elements::Row, void]
50
- def each: () { (Elements::Row) -> void } -> void
51
- | () -> Enumerator[Elements::Row, void]
193
+ # : (?trim_empty_rows: bool?, ?pad_empty_rows: bool?, ?pad_empty_cells: bool?) { (Elements::Row) -> void } -> void
194
+ # : (?trim_empty_rows: bool?, ?pad_empty_rows: bool?, ?pad_empty_cells: bool?) -> Enumerator[Elements::Row, void]
195
+ def each: (?trim_empty_rows: bool?, ?pad_empty_rows: bool?, ?pad_empty_cells: bool?) { (Elements::Row) -> void } -> void
196
+ | (?trim_empty_rows: bool?, ?pad_empty_rows: bool?, ?pad_empty_cells: bool?) -> Enumerator[Elements::Row, void]
52
197
 
53
198
  # Iterate over rows in the worksheet.
54
199
  #
@@ -57,14 +202,49 @@ module Xlsxrb
57
202
  # puts "Row #{row.index}: #{row.to_a.inspect}"
58
203
  # end
59
204
  #
60
- # @yield [row]
61
- # @yieldparam row [Elements::Row]
62
- # @return [Enumerator, void]
205
+ # @overload each_row(trim_empty_rows: nil, pad_empty_rows: nil, pad_empty_cells: nil, &block)
206
+ # @param trim_empty_rows [Boolean, nil] Whether to omit trailing empty rows.
207
+ # @param pad_empty_rows [Boolean, nil] Whether to yield empty rows for skipped row numbers.
208
+ # @param pad_empty_cells [Boolean, nil] Whether to pad missing cells within rows.
209
+ # @yield [row]
210
+ # @yieldparam row [Elements::Row]
211
+ # @return [void]
212
+ #
213
+ # @overload each_row(trim_empty_rows: nil, pad_empty_rows: nil, pad_empty_cells: nil)
214
+ # @param trim_empty_rows [Boolean, nil] Whether to omit trailing empty rows.
215
+ # @param pad_empty_rows [Boolean, nil] Whether to yield empty rows for skipped row numbers.
216
+ # @param pad_empty_cells [Boolean, nil] Whether to pad missing cells within rows.
217
+ # @return [Enumerator<Elements::Row, void>]
218
+ #
63
219
  # @api public
64
- # : () { (Elements::Row) -> void } -> void
65
- # : () -> Enumerator[Elements::Row, void]
66
- def each_row: () { (Elements::Row) -> void } -> void
67
- | () -> Enumerator[Elements::Row, void]
220
+ # : (?trim_empty_rows: bool?, ?pad_empty_rows: bool?, ?pad_empty_cells: bool?) { (Elements::Row) -> void } -> void
221
+ # : (?trim_empty_rows: bool?, ?pad_empty_rows: bool?, ?pad_empty_cells: bool?) -> Enumerator[Elements::Row, void]
222
+ def each_row: (?trim_empty_rows: bool?, ?pad_empty_rows: bool?, ?pad_empty_cells: bool?) { (Elements::Row) -> void } -> void
223
+ | (?trim_empty_rows: bool?, ?pad_empty_rows: bool?, ?pad_empty_cells: bool?) -> Enumerator[Elements::Row, void]
224
+
225
+ # Iterates over row values as Arrays.
226
+ #
227
+ # @overload each_row_values(type_cast: false, trim_empty_rows: nil, pad_empty_rows: nil, pad_empty_cells: nil, &block)
228
+ # @param type_cast [Boolean] Whether to coerce date/time serial numbers into Date/Time instances.
229
+ # @param trim_empty_rows [Boolean, nil] Whether to omit trailing empty rows.
230
+ # @param pad_empty_rows [Boolean, nil] Whether to yield empty rows for skipped row numbers.
231
+ # @param pad_empty_cells [Boolean, nil] Whether to pad missing cells within rows.
232
+ # @yield [values]
233
+ # @yieldparam values [Array<Object>] Row values array.
234
+ # @return [void]
235
+ #
236
+ # @overload each_row_values(type_cast: false, trim_empty_rows: nil, pad_empty_rows: nil, pad_empty_cells: nil)
237
+ # @param type_cast [Boolean] Whether to coerce date/time serial numbers into Date/Time instances.
238
+ # @param trim_empty_rows [Boolean, nil] Whether to omit trailing empty rows.
239
+ # @param pad_empty_rows [Boolean, nil] Whether to yield empty rows for skipped row numbers.
240
+ # @param pad_empty_cells [Boolean, nil] Whether to pad missing cells within rows.
241
+ # @return [Enumerator<Array<Object>, void>]
242
+ #
243
+ # @api public
244
+ # : (?type_cast: bool, ?trim_empty_rows: bool?, ?pad_empty_rows: bool?, ?pad_empty_cells: bool?) { (Array[untyped]) -> void } -> void
245
+ # : (?type_cast: bool, ?trim_empty_rows: bool?, ?pad_empty_rows: bool?, ?pad_empty_cells: bool?) -> Enumerator[Array[untyped], void]
246
+ def each_row_values: (?type_cast: bool, ?trim_empty_rows: bool?, ?pad_empty_rows: bool?, ?pad_empty_cells: bool?) { (Array[untyped]) -> void } -> void
247
+ | (?type_cast: bool, ?trim_empty_rows: bool?, ?pad_empty_rows: bool?, ?pad_empty_cells: bool?) -> Enumerator[Array[untyped], void]
68
248
 
69
249
  # Iterate over all cells across rows.
70
250
  #
@@ -77,12 +257,89 @@ module Xlsxrb
77
257
  def each_cell: () { (Elements::Cell) -> void } -> void
78
258
  | () -> Enumerator[Elements::Cell, void]
79
259
 
260
+ # Returns all images anchored at a specific cell reference or 0-based coordinate.
261
+ #
262
+ # @param ref_or_row [String, Symbol, Integer] Cell reference (e.g. "A1") or 0-based row index.
263
+ # @param col [Integer, nil] Optional 0-based column index.
264
+ # @return [Array<Elements::Image>]
265
+ # @api public
266
+ # : (String | Symbol | Integer ref_or_row, ?Integer? col) -> Array[Elements::Image]
267
+ def images_at: (String | Symbol | Integer ref_or_row, ?Integer? col) -> Array[Elements::Image]
268
+
269
+ # Yields self with images loaded or returns self.
270
+ #
271
+ # @yield [sheet]
272
+ # @yieldparam sheet [Elements::Worksheet]
273
+ # @return [Elements::Worksheet, void]
274
+ # @api public
275
+ # : () { (Elements::Worksheet) -> void } -> void
276
+ # : () -> Elements::Worksheet
277
+ def with_images: () { (Elements::Worksheet) -> void } -> void
278
+ | () -> Elements::Worksheet
279
+
80
280
  # Returns whether the worksheet is valid according to OOXML specifications.
81
281
  #
82
282
  # @return [Boolean]
83
283
  # : () -> bool
84
284
  def valid?: () -> bool
85
285
 
286
+ # Returns whether the worksheet is hidden (:hidden or :very_hidden).
287
+ #
288
+ # @return [Boolean]
289
+ # @api public
290
+ # : () -> bool
291
+ def hidden?: () -> bool
292
+
293
+ # Returns whether the worksheet is visible.
294
+ #
295
+ # @return [Boolean]
296
+ # @api public
297
+ # : () -> bool
298
+ def visible?: () -> bool
299
+
300
+ # Returns hyperlink metadata for the given cell reference, or nil.
301
+ #
302
+ # @param ref_or_row [String, Symbol, Integer] Cell reference (e.g. "A1") or 0-based row index.
303
+ # @param col [Integer, nil] Optional 0-based column index if ref_or_row is a row index.
304
+ # @return [Hash, nil]
305
+ # @api public
306
+ # : (String | Symbol | Integer ref_or_row, ?Integer? col) -> Hash[Symbol, untyped]?
307
+ def hyperlink: (String | Symbol | Integer ref_or_row, ?Integer? col) -> Hash[Symbol, untyped]?
308
+
309
+ # Returns comment metadata for the given cell reference, or nil.
310
+ #
311
+ # @param ref_or_row [String, Symbol, Integer] Cell reference (e.g. "A1") or 0-based row index.
312
+ # @param col [Integer, nil] Optional 0-based column index if ref_or_row is a row index.
313
+ # @return [Hash, nil]
314
+ # @api public
315
+ # : (String | Symbol | Integer ref_or_row, ?Integer? col) -> Hash[Symbol, untyped]?
316
+ def comment: (String | Symbol | Integer ref_or_row, ?Integer? col) -> Hash[Symbol, untyped]?
317
+
318
+ # Returns comments indexed by cell reference.
319
+ #
320
+ # @return [Hash<String, Hash[Symbol, untyped]>]
321
+ # @api public
322
+ # : () -> Hash[String, Hash[Symbol, untyped]]
323
+ def comments_by_ref: () -> Hash[String, Hash[Symbol, untyped]]
324
+
325
+ # Access a cell by reference or 0-based coordinates.
326
+ #
327
+ # @param ref_or_row [String, Symbol, Integer] Cell reference (e.g. "A1") or 0-based row index.
328
+ # @param col [Integer, nil] Optional 0-based column index.
329
+ # @return [Elements::Cell, nil]
330
+ # @api public
331
+ # : (String | Symbol | Integer ref_or_row, ?Integer? col) -> Elements::Cell?
332
+ def cell: (String | Symbol | Integer ref_or_row, ?Integer? col) -> Elements::Cell?
333
+
334
+ # Returns the formatted string representation of a cell's value.
335
+ #
336
+ # @param ref_or_row [String, Symbol, Integer] Cell reference (e.g. "A1") or 0-based row index.
337
+ # @param col [Integer, nil] Optional 0-based column index.
338
+ # @return [String, nil]
339
+ # @api public
340
+ # : (String | Symbol | Integer ref_or_row, ?Integer? col) -> String?
341
+ def formatted_value: (String | Symbol | Integer ref_or_row, ?Integer? col) -> String?
342
+
86
343
  # Returns a new Worksheet with the specified cell updated.
87
344
  #
88
345
  # @example
@@ -92,10 +349,12 @@ module Xlsxrb
92
349
  # @param value [Object] The new cell value.
93
350
  # @param style_index [Integer, String, nil] Optional new style index.
94
351
  # @param formula [Elements::Formula, nil] Optional new formula.
352
+ # @param hyperlink [Hash, String, nil] Optional new hyperlink.
353
+ # @param comment [Hash, String, nil] Optional new comment.
95
354
  # @return [Worksheet] A new Worksheet instance.
96
355
  # @api public
97
- # : (String ref, ?value: untyped, ?style_index: Integer | String | nil, ?formula: Elements::Formula?) -> Elements::Worksheet
98
- def update_cell: (String ref, ?value: untyped, ?style_index: Integer | String | nil, ?formula: Elements::Formula?) -> Elements::Worksheet
356
+ # : (String ref, ?value: untyped, ?style_index: Integer | String | nil, ?formula: Elements::Formula?, ?hyperlink: (Hash[Symbol, untyped] | String)?, ?comment: (Hash[Symbol, untyped] | String)?) -> Elements::Worksheet
357
+ 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
99
358
 
100
359
  # Returns a new Worksheet with attributes replaced (Data-like behavior).
101
360
  #
@@ -143,6 +402,11 @@ module Xlsxrb
143
402
  # @return [Array<String>] List of errors.
144
403
  # : (untyped name, untyped rows) -> Array[String]
145
404
  def self.validate: (untyped name, untyped rows) -> Array[String]
405
+
406
+ private
407
+
408
+ # : () -> String?
409
+ def compute_dimension: () -> String?
146
410
  end
147
411
  end
148
412
  end
@@ -0,0 +1,132 @@
1
+ # Generated from lib/xlsxrb/number_formatter.rb with RBS::Inline
2
+
3
+ module Xlsxrb
4
+ # Formats cell values according to OpenXML formatCode strings.
5
+ # Evaluates and converts numeric, currency, percentage, date/time, scientific,
6
+ # and accounting format patterns into string representations.
7
+ #
8
+ # @api public
9
+ module NumberFormatter
10
+ # Built-in date and time format code strings.
11
+ DATE_PATTERNS: untyped
12
+
13
+ # Formats a cell value according to an Excel format code string.
14
+ #
15
+ # @param value [Object, nil] The cell's raw or typed value.
16
+ # @param format_code [String, nil] Excel format code pattern.
17
+ # @param date1904 [Boolean] Whether the 1904 date system is active.
18
+ # @return [String] Formatted string representation.
19
+ # @api public
20
+ # : (untyped value, ?String? format_code, ?date1904: bool) -> String
21
+ def self.format: (untyped value, ?String? format_code, ?date1904: bool) -> String
22
+
23
+ # Resolves the format code string for a given style index from a styles definition hash.
24
+ #
25
+ # @param style_index [Integer, nil] 0-based style index in cellXfs.
26
+ # @param styles [Hash, nil] Parsed styles hash.
27
+ # @return [String, nil] Format code string, or nil if not found.
28
+ # @api public
29
+ # : (Integer? style_index, untyped styles) -> String?
30
+ def self.format_code_for: (Integer? style_index, untyped styles) -> String?
31
+
32
+ # Returns the classified format category for a format code string.
33
+ #
34
+ # @param format_code [String, nil] Format code string.
35
+ # @return [Symbol, nil] :date, :datetime, :time, :number, :text, :general, or nil.
36
+ # @api public
37
+ # : (String? format_code) -> Symbol?
38
+ def self.format_type: (String? format_code) -> Symbol?
39
+
40
+ # Checks whether a format code string represents a date, datetime, or time pattern.
41
+ #
42
+ # @param format_code [String, nil]
43
+ # @param num_fmt_id [Integer, nil]
44
+ # @return [Boolean]
45
+ # : (String? format_code, ?Integer? num_fmt_id) -> bool
46
+ def self.date_format?: (String? format_code, ?Integer? num_fmt_id) -> bool
47
+
48
+ # Checks whether a format code string represents a date-only pattern.
49
+ #
50
+ # @param format_code [String, nil]
51
+ # @param num_fmt_id [Integer, nil]
52
+ # @return [Boolean]
53
+ # @api public
54
+ # : (String? format_code, ?Integer? num_fmt_id) -> bool
55
+ def self.date_only_format?: (String? format_code, ?Integer? num_fmt_id) -> bool
56
+
57
+ # Checks whether a format code string represents a datetime pattern.
58
+ #
59
+ # @param format_code [String, nil]
60
+ # @param num_fmt_id [Integer, nil]
61
+ # @return [Boolean]
62
+ # @api public
63
+ # : (String? format_code, ?Integer? num_fmt_id) -> bool
64
+ def self.datetime_format?: (String? format_code, ?Integer? num_fmt_id) -> bool
65
+
66
+ # Checks whether a format code string represents a time-only pattern.
67
+ #
68
+ # @param format_code [String, nil]
69
+ # @param num_fmt_id [Integer, nil]
70
+ # @return [Boolean]
71
+ # @api public
72
+ # : (String? format_code, ?Integer? num_fmt_id) -> bool
73
+ def self.time_format?: (String? format_code, ?Integer? num_fmt_id) -> bool
74
+
75
+ # Returns the format category Symbol for a style index and styles definition.
76
+ #
77
+ # @param style_index [Integer, nil]
78
+ # @param styles [untyped]
79
+ # @return [Symbol, nil]
80
+ # @api public
81
+ # : (Integer? style_index, untyped styles) -> Symbol?
82
+ def self.format_type_for: (Integer? style_index, untyped styles) -> Symbol?
83
+
84
+ # Checks whether a style index represents a date, datetime, or time format.
85
+ #
86
+ # @param style_index [Integer, nil]
87
+ # @param styles [untyped]
88
+ # @return [Boolean]
89
+ # @api public
90
+ # : (Integer? style_index, untyped styles) -> bool
91
+ def self.date_format_for?: (Integer? style_index, untyped styles) -> bool
92
+
93
+ # Checks whether a style index represents a datetime format.
94
+ #
95
+ # @param style_index [Integer, nil]
96
+ # @param styles [untyped]
97
+ # @return [Boolean]
98
+ # @api public
99
+ # : (Integer? style_index, untyped styles) -> bool
100
+ def self.datetime_format_for?: (Integer? style_index, untyped styles) -> bool
101
+
102
+ # Checks whether a style index represents a time format.
103
+ #
104
+ # @param style_index [Integer, nil]
105
+ # @param styles [untyped]
106
+ # @return [Boolean]
107
+ # @api public
108
+ # : (Integer? style_index, untyped styles) -> bool
109
+ def self.time_format_for?: (Integer? style_index, untyped styles) -> bool
110
+
111
+ # Checks whether a style index represents a date-only format.
112
+ #
113
+ # @param style_index [Integer, nil]
114
+ # @param styles [untyped]
115
+ # @return [Boolean]
116
+ # @api public
117
+ # : (Integer? style_index, untyped styles) -> bool
118
+ def self.date_only_format_for?: (Integer? style_index, untyped styles) -> bool
119
+
120
+ private def self.default_format: (untyped value) -> untyped
121
+
122
+ private def self.split_sections: (untyped code) -> untyped
123
+
124
+ private def self.format_number: (untyped value, untyped code) -> untyped
125
+
126
+ private def self.format_single_number: (untyped num, untyped pattern, untyped is_neg) -> untyped
127
+
128
+ private def self.format_datetime: (untyped datetime, untyped format_code) -> untyped
129
+
130
+ private def self.excel_to_strftime: (untyped format_code) -> untyped
131
+ end
132
+ end
@@ -158,6 +158,12 @@ module Xlsxrb
158
158
  # Returns workbook properties (e.g. { date1904: false, default_theme_version: 166925 }).
159
159
  def workbook_properties: () -> untyped
160
160
 
161
+ # Returns whether the workbook uses the 1904 date system.
162
+ #
163
+ # @return [Boolean]
164
+ # : () -> bool
165
+ def date1904?: () -> bool
166
+
161
167
  # Returns the workbook conformance class ("transitional" or "strict"), or nil if not set.
162
168
  def conformance: () -> untyped
163
169
 
@@ -14,6 +14,8 @@ module Xlsxrb
14
14
  def self.fast_scan: (untyped xml_src) -> untyped
15
15
 
16
16
  def self.extract_multi_t: (untyped xml, untyped from, untyped to) -> untyped
17
+
18
+ def self.normalize_newlines: (untyped str) -> untyped
17
19
  end
18
20
  end
19
21
  end
@@ -3,9 +3,10 @@
3
3
  module Xlsxrb
4
4
  module Ooxml
5
5
  # SAX-based parser for xl/styles.xml.
6
- # Returns a 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.
7
7
  class StylesParser
8
- def self.parse: (untyped xml_string) -> untyped
8
+ # : (String? xml_string) -> Elements::Styles
9
+ def self.parse: (String? xml_string) -> Elements::Styles
9
10
 
10
11
  # SAX listener for parsing styles.xml content.
11
12
  class Listener
@@ -35,6 +36,8 @@ module Xlsxrb
35
36
 
36
37
  def handle_alignment: (untyped attrs) -> untyped
37
38
 
39
+ def handle_protection: (untyped attrs) -> untyped
40
+
38
41
  def finalize_xf: () -> untyped
39
42
 
40
43
  def extract_color: (untyped attrs) -> untyped
@@ -9,6 +9,11 @@ module Xlsxrb
9
9
 
10
10
  EPOCH_1900_JD: untyped
11
11
 
12
+ # Excel 1904 date system epoch.
13
+ EPOCH_1904: untyped
14
+
15
+ EPOCH_1904_JD: untyped
16
+
12
17
  # Built-in number format codes defined by SpreadsheetML.
13
18
  BUILTIN_NUM_FMT_CODES: untyped
14
19
 
@@ -21,17 +26,21 @@ module Xlsxrb
21
26
  # Default date-time format code used by Writer for Time cells.
22
27
  DEFAULT_DATETIME_FORMAT: ::String
23
28
 
24
- # Converts a Date to an Excel serial number (1900 system).
25
- def self.date_to_serial: (untyped date) -> untyped
29
+ # Converts a Date to an Excel serial number (1900 or 1904 system).
30
+ # : (Date date, ?date1904: bool) -> untyped
31
+ def self.date_to_serial: (Date date, ?date1904: bool) -> untyped
26
32
 
27
- # Converts an Excel serial number (1900 system) to a Date.
28
- def self.serial_to_date: (untyped serial) -> untyped
33
+ # Converts an Excel serial number (1900 or 1904 system) to a Date.
34
+ # : (Numeric serial, ?date1904: bool) -> Date
35
+ def self.serial_to_date: (Numeric serial, ?date1904: bool) -> Date
29
36
 
30
- # Converts a Time to a fractional Excel serial number (1900 system).
31
- def self.datetime_to_serial: (untyped time) -> untyped
37
+ # Converts a Time to a fractional Excel serial number (1900 or 1904 system).
38
+ # : (Time time, ?date1904: bool) -> Float
39
+ def self.datetime_to_serial: (Time time, ?date1904: bool) -> Float
32
40
 
33
- # Converts a fractional Excel serial number to a Time (1900 system, UTC).
34
- def self.serial_to_datetime: (untyped serial) -> untyped
41
+ # Converts a fractional Excel serial number to a Time (1900 or 1904 system, UTC).
42
+ # : (Numeric serial, ?date1904: bool) -> Time
43
+ def self.serial_to_datetime: (Numeric serial, ?date1904: bool) -> Time
35
44
 
36
45
  # Hashes a plain-text password for use with sheet/workbook protection.
37
46
  # Returns { algorithm_name:, hash_value:, salt_value:, spin_count: }.
@@ -7,19 +7,25 @@ module Xlsxrb
7
7
  class WorkbookParser
8
8
  def self.parse: (untyped xml_string) -> untyped
9
9
 
10
- # SAX listener for workbook.xml sheets.
10
+ def self.parse_with_properties: (untyped xml_string) -> untyped
11
+
12
+ # SAX listener for workbook.xml sheets, properties, and defined names.
11
13
  class Listener
12
14
  include REXML::SAX2Listener
13
15
 
14
16
  attr_reader sheets: untyped
15
17
 
18
+ attr_reader date1904: untyped
19
+
20
+ attr_reader defined_names: untyped
21
+
16
22
  def initialize: () -> untyped
17
23
 
18
24
  def start_element: (untyped _uri, untyped localname, untyped _qname, untyped attrs) -> untyped
19
25
 
20
- def end_element: (untyped _uri, untyped _localname, untyped _qname) -> untyped
26
+ def characters: (untyped text) -> untyped
21
27
 
22
- def characters: (untyped _text) -> untyped
28
+ def end_element: (untyped _uri, untyped localname, untyped _qname) -> untyped
23
29
  end
24
30
  end
25
31
 
@@ -68,7 +68,7 @@ module Xlsxrb
68
68
 
69
69
  def write_shared_strings_xml: (untyped zip) -> untyped
70
70
 
71
- def write_worksheet_xml: (untyped io, untyped sheet, ?drawing_rid: untyped, ?sheet_protection: 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, ?freeze_pane: untyped, ?split_pane: untyped, ?selection: untyped, ?sheet_view: untyped, ?sheet_properties: untyped, ?tables: untyped, ?table_start_rid: untyped, ?legacy_drawing_rid: untyped, ?sparkline_groups: untyped) -> untyped
71
+ def write_worksheet_xml: (untyped io, untyped sheet, ?drawing_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, ?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) -> untyped
72
72
 
73
73
  def build_table_xml: (untyped tbl, untyped table_id) -> untyped
74
74