xlsxrb 0.1.13 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +57 -0
- data/README.md +2 -0
- data/lib/xlsxrb/colors.rb +118 -0
- data/lib/xlsxrb/elements/cell.rb +205 -16
- data/lib/xlsxrb/elements/column.rb +6 -4
- data/lib/xlsxrb/elements/coordinate_access.rb +32 -0
- data/lib/xlsxrb/elements/image.rb +128 -0
- data/lib/xlsxrb/elements/row.rb +206 -9
- data/lib/xlsxrb/elements/styles.rb +157 -0
- data/lib/xlsxrb/elements/types.rb +95 -1
- data/lib/xlsxrb/elements/workbook.rb +85 -4
- data/lib/xlsxrb/elements/worksheet.rb +424 -29
- data/lib/xlsxrb/elements.rb +2 -0
- data/lib/xlsxrb/number_formatter.rb +429 -0
- data/lib/xlsxrb/ooxml/cfb.rb +1 -1
- data/lib/xlsxrb/ooxml/reader/listeners/core_listeners.rb +7 -5
- data/lib/xlsxrb/ooxml/reader/listeners/drawing_listeners.rb +11 -4
- data/lib/xlsxrb/ooxml/reader.rb +12 -14
- data/lib/xlsxrb/ooxml/shared_strings_parser.rb +7 -1
- data/lib/xlsxrb/ooxml/styles_parser.rb +39 -9
- data/lib/xlsxrb/ooxml/utils.rb +34 -18
- data/lib/xlsxrb/ooxml/workbook_parser.rb +53 -15
- data/lib/xlsxrb/ooxml/workbook_writer.rb +65 -14
- data/lib/xlsxrb/ooxml/worksheet_parser.rb +319 -79
- data/lib/xlsxrb/ooxml/worksheet_writer.rb +206 -61
- data/lib/xlsxrb/ooxml/writer/features_xml.rb +4 -2
- data/lib/xlsxrb/ooxml/writer.rb +14 -0
- data/lib/xlsxrb/ooxml/zip_reader.rb +109 -25
- data/lib/xlsxrb/stream_row.rb +243 -16
- data/lib/xlsxrb/stream_sheet.rb +414 -15
- data/lib/xlsxrb/stream_writer.rb +213 -17
- data/lib/xlsxrb/style_builder.rb +308 -22
- data/lib/xlsxrb/utils.rb +158 -0
- data/lib/xlsxrb/version.rb +1 -1
- data/lib/xlsxrb/workbook_builder.rb +73 -3
- data/lib/xlsxrb/worksheet_builder.rb +227 -16
- data/lib/xlsxrb.rb +578 -79
- data/sig/generated/xlsxrb/colors.rbs +40 -0
- data/sig/generated/xlsxrb/elements/cell.rbs +113 -8
- data/sig/generated/xlsxrb/elements/column.rbs +3 -2
- data/sig/generated/xlsxrb/elements/coordinate_access.rbs +18 -0
- data/sig/generated/xlsxrb/elements/image.rbs +82 -0
- data/sig/generated/xlsxrb/elements/row.rbs +83 -4
- data/sig/generated/xlsxrb/elements/styles.rbs +79 -0
- data/sig/generated/xlsxrb/elements/types.rbs +43 -0
- data/sig/generated/xlsxrb/elements/workbook.rbs +51 -2
- data/sig/generated/xlsxrb/elements/worksheet.rbs +231 -18
- data/sig/generated/xlsxrb/number_formatter.rbs +132 -0
- data/sig/generated/xlsxrb/ooxml/reader.rbs +6 -0
- data/sig/generated/xlsxrb/ooxml/shared_strings_parser.rbs +2 -0
- data/sig/generated/xlsxrb/ooxml/styles_parser.rbs +5 -2
- data/sig/generated/xlsxrb/ooxml/utils.rbs +17 -8
- data/sig/generated/xlsxrb/ooxml/workbook_parser.rbs +9 -3
- data/sig/generated/xlsxrb/ooxml/worksheet_parser.rbs +28 -6
- data/sig/generated/xlsxrb/ooxml/worksheet_writer.rbs +3 -1
- data/sig/generated/xlsxrb/ooxml/writer.rbs +2 -0
- data/sig/generated/xlsxrb/ooxml/zip_reader.rbs +10 -0
- data/sig/generated/xlsxrb/stream_row.rbs +100 -6
- data/sig/generated/xlsxrb/stream_sheet.rbs +247 -13
- data/sig/generated/xlsxrb/stream_writer.rbs +120 -14
- data/sig/generated/xlsxrb/style_builder.rbs +55 -18
- data/sig/generated/xlsxrb/utils.rbs +119 -0
- data/sig/generated/xlsxrb/workbook_builder.rbs +26 -0
- data/sig/generated/xlsxrb/worksheet_builder.rbs +107 -11
- data/sig/generated/xlsxrb.rbs +186 -27
- metadata +11 -1
|
@@ -21,18 +21,101 @@ 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_writer dimension: untyped
|
|
51
|
+
|
|
52
|
+
alias conditional_formats conditional_formatting
|
|
53
|
+
|
|
28
54
|
# @param name [String] The worksheet name (max 31 characters).
|
|
29
55
|
# @param rows [Array<Elements::Row>] Rows in the sheet.
|
|
30
56
|
# @param columns [Array<Elements::Column>] Column definitions.
|
|
31
57
|
# @param charts [Array<Hash>] Charts in the sheet.
|
|
58
|
+
# @param conditional_formatting [Array<Hash>, nil] Conditional formatting rules.
|
|
59
|
+
# @param data_validations [Array<Hash>] Data validation rules.
|
|
32
60
|
# @param unmapped_data [Hash] Additional metadata for round-tripping.
|
|
33
61
|
# @param errors [Array<String>, nil] Validation errors.
|
|
34
|
-
#
|
|
35
|
-
|
|
62
|
+
# @param conditional_formats [Array<Hash>, nil] Alias for conditional_formatting.
|
|
63
|
+
# @param state [Symbol] Sheet visibility state (:visible, :hidden, or :very_hidden).
|
|
64
|
+
# @param hyperlinks [Hash{String => Hash}] Hyperlink mappings by cell reference.
|
|
65
|
+
# @param comments [Array<Hash>] Comments and notes in the sheet.
|
|
66
|
+
# @param images [Array<Elements::Image>] Embedded images in the sheet.
|
|
67
|
+
# @param styles [Hash, nil] Optional parsed styles hash.
|
|
68
|
+
# @param dimension [String, nil] Sheet dimension reference string (e.g. "A1:Z50000").
|
|
69
|
+
# @param trim_empty_rows [Boolean] Whether to omit trailing empty rows during iteration.
|
|
70
|
+
# @param pad_empty_rows [Boolean] Whether to yield empty rows for skipped row numbers.
|
|
71
|
+
# @param pad_empty_cells [Boolean] Whether to pad missing cells within rows.
|
|
72
|
+
# @param print_area [String, nil] Sheet print area range (e.g. "A1:H50").
|
|
73
|
+
# @param print_titles [Hash, nil] Repeating print title rows/cols (e.g. { rows: "1:2", cols: "A:B" }).
|
|
74
|
+
# @param sparkline_groups [Array<Hash>] Sparkline groups in the sheet.
|
|
75
|
+
# : (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, Hash[Symbol, 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]]) -> void
|
|
76
|
+
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, Hash[Symbol, 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]]) -> void
|
|
77
|
+
|
|
78
|
+
# Returns whether trailing empty rows are omitted during iteration.
|
|
79
|
+
#
|
|
80
|
+
# @return [Boolean]
|
|
81
|
+
# @api public
|
|
82
|
+
# : () -> bool
|
|
83
|
+
def trim_empty_rows?: () -> bool
|
|
84
|
+
|
|
85
|
+
alias trim_empty_rows trim_empty_rows?
|
|
86
|
+
|
|
87
|
+
# Returns whether skipped rows are padded during iteration.
|
|
88
|
+
#
|
|
89
|
+
# @return [Boolean]
|
|
90
|
+
# @api public
|
|
91
|
+
# : () -> bool
|
|
92
|
+
def pad_empty_rows?: () -> bool
|
|
93
|
+
|
|
94
|
+
alias pad_empty_rows pad_empty_rows?
|
|
95
|
+
|
|
96
|
+
# Returns whether missing cells within rows are padded during iteration.
|
|
97
|
+
#
|
|
98
|
+
# @return [Boolean]
|
|
99
|
+
# @api public
|
|
100
|
+
# : () -> bool
|
|
101
|
+
def pad_empty_cells?: () -> bool
|
|
102
|
+
|
|
103
|
+
alias pad_empty_cells pad_empty_cells?
|
|
104
|
+
|
|
105
|
+
# Returns whether the worksheet uses the 1904 date system.
|
|
106
|
+
#
|
|
107
|
+
# @return [Boolean]
|
|
108
|
+
# @api public
|
|
109
|
+
# : () -> bool
|
|
110
|
+
def date1904?: () -> bool
|
|
111
|
+
|
|
112
|
+
# Returns the worksheet dimension reference string (e.g. "A1:Z50000"),
|
|
113
|
+
# or computes it dynamically from rows if not explicitly set.
|
|
114
|
+
#
|
|
115
|
+
# @return [String, nil]
|
|
116
|
+
# @api public
|
|
117
|
+
# : () -> String?
|
|
118
|
+
def dimension: () -> String?
|
|
36
119
|
|
|
37
120
|
# Iterate over rows in the worksheet.
|
|
38
121
|
#
|
|
@@ -41,14 +124,25 @@ module Xlsxrb
|
|
|
41
124
|
# puts row.to_a.inspect
|
|
42
125
|
# end
|
|
43
126
|
#
|
|
44
|
-
# @
|
|
45
|
-
#
|
|
46
|
-
#
|
|
127
|
+
# @overload each(trim_empty_rows: nil, pad_empty_rows: nil, pad_empty_cells: nil, &block)
|
|
128
|
+
# @param trim_empty_rows [Boolean, nil] Whether to omit trailing empty rows.
|
|
129
|
+
# @param pad_empty_rows [Boolean, nil] Whether to yield empty rows for skipped row numbers.
|
|
130
|
+
# @param pad_empty_cells [Boolean, nil] Whether to pad missing cells within rows.
|
|
131
|
+
# @yield [row]
|
|
132
|
+
# @yieldparam row [Elements::Row]
|
|
133
|
+
# @return [void]
|
|
134
|
+
#
|
|
135
|
+
# @overload each(trim_empty_rows: nil, pad_empty_rows: nil, pad_empty_cells: nil)
|
|
136
|
+
# @param trim_empty_rows [Boolean, nil] Whether to omit trailing empty rows.
|
|
137
|
+
# @param pad_empty_rows [Boolean, nil] Whether to yield empty rows for skipped row numbers.
|
|
138
|
+
# @param pad_empty_cells [Boolean, nil] Whether to pad missing cells within rows.
|
|
139
|
+
# @return [Enumerator<Elements::Row, void>]
|
|
140
|
+
#
|
|
47
141
|
# @api public
|
|
48
|
-
# : () { (Elements::Row) -> void } -> void
|
|
49
|
-
# : () -> Enumerator[Elements::Row, void]
|
|
50
|
-
def each: () { (Elements::Row) -> void } -> void
|
|
51
|
-
| () -> Enumerator[Elements::Row, void]
|
|
142
|
+
# : (?trim_empty_rows: bool?, ?pad_empty_rows: bool?, ?pad_empty_cells: bool?) { (Elements::Row) -> void } -> void
|
|
143
|
+
# : (?trim_empty_rows: bool?, ?pad_empty_rows: bool?, ?pad_empty_cells: bool?) -> Enumerator[Elements::Row, void]
|
|
144
|
+
def each: (?trim_empty_rows: bool?, ?pad_empty_rows: bool?, ?pad_empty_cells: bool?) { (Elements::Row) -> void } -> void
|
|
145
|
+
| (?trim_empty_rows: bool?, ?pad_empty_rows: bool?, ?pad_empty_cells: bool?) -> Enumerator[Elements::Row, void]
|
|
52
146
|
|
|
53
147
|
# Iterate over rows in the worksheet.
|
|
54
148
|
#
|
|
@@ -57,14 +151,49 @@ module Xlsxrb
|
|
|
57
151
|
# puts "Row #{row.index}: #{row.to_a.inspect}"
|
|
58
152
|
# end
|
|
59
153
|
#
|
|
60
|
-
# @
|
|
61
|
-
#
|
|
62
|
-
#
|
|
154
|
+
# @overload each_row(trim_empty_rows: nil, pad_empty_rows: nil, pad_empty_cells: nil, &block)
|
|
155
|
+
# @param trim_empty_rows [Boolean, nil] Whether to omit trailing empty rows.
|
|
156
|
+
# @param pad_empty_rows [Boolean, nil] Whether to yield empty rows for skipped row numbers.
|
|
157
|
+
# @param pad_empty_cells [Boolean, nil] Whether to pad missing cells within rows.
|
|
158
|
+
# @yield [row]
|
|
159
|
+
# @yieldparam row [Elements::Row]
|
|
160
|
+
# @return [void]
|
|
161
|
+
#
|
|
162
|
+
# @overload each_row(trim_empty_rows: nil, pad_empty_rows: nil, pad_empty_cells: nil)
|
|
163
|
+
# @param trim_empty_rows [Boolean, nil] Whether to omit trailing empty rows.
|
|
164
|
+
# @param pad_empty_rows [Boolean, nil] Whether to yield empty rows for skipped row numbers.
|
|
165
|
+
# @param pad_empty_cells [Boolean, nil] Whether to pad missing cells within rows.
|
|
166
|
+
# @return [Enumerator<Elements::Row, void>]
|
|
167
|
+
#
|
|
63
168
|
# @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]
|
|
169
|
+
# : (?trim_empty_rows: bool?, ?pad_empty_rows: bool?, ?pad_empty_cells: bool?) { (Elements::Row) -> void } -> void
|
|
170
|
+
# : (?trim_empty_rows: bool?, ?pad_empty_rows: bool?, ?pad_empty_cells: bool?) -> Enumerator[Elements::Row, void]
|
|
171
|
+
def each_row: (?trim_empty_rows: bool?, ?pad_empty_rows: bool?, ?pad_empty_cells: bool?) { (Elements::Row) -> void } -> void
|
|
172
|
+
| (?trim_empty_rows: bool?, ?pad_empty_rows: bool?, ?pad_empty_cells: bool?) -> Enumerator[Elements::Row, void]
|
|
173
|
+
|
|
174
|
+
# Iterates over row values as Arrays.
|
|
175
|
+
#
|
|
176
|
+
# @overload each_row_values(type_cast: false, trim_empty_rows: nil, pad_empty_rows: nil, pad_empty_cells: nil, &block)
|
|
177
|
+
# @param type_cast [Boolean] Whether to coerce date/time serial numbers into Date/Time instances.
|
|
178
|
+
# @param trim_empty_rows [Boolean, nil] Whether to omit trailing empty rows.
|
|
179
|
+
# @param pad_empty_rows [Boolean, nil] Whether to yield empty rows for skipped row numbers.
|
|
180
|
+
# @param pad_empty_cells [Boolean, nil] Whether to pad missing cells within rows.
|
|
181
|
+
# @yield [values]
|
|
182
|
+
# @yieldparam values [Array<Object>] Row values array.
|
|
183
|
+
# @return [void]
|
|
184
|
+
#
|
|
185
|
+
# @overload each_row_values(type_cast: false, trim_empty_rows: nil, pad_empty_rows: nil, pad_empty_cells: nil)
|
|
186
|
+
# @param type_cast [Boolean] Whether to coerce date/time serial numbers into Date/Time instances.
|
|
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<Array<Object>, void>]
|
|
191
|
+
#
|
|
192
|
+
# @api public
|
|
193
|
+
# : (?type_cast: bool, ?trim_empty_rows: bool?, ?pad_empty_rows: bool?, ?pad_empty_cells: bool?) { (Array[untyped]) -> void } -> void
|
|
194
|
+
# : (?type_cast: bool, ?trim_empty_rows: bool?, ?pad_empty_rows: bool?, ?pad_empty_cells: bool?) -> Enumerator[Array[untyped], void]
|
|
195
|
+
def each_row_values: (?type_cast: bool, ?trim_empty_rows: bool?, ?pad_empty_rows: bool?, ?pad_empty_cells: bool?) { (Array[untyped]) -> void } -> void
|
|
196
|
+
| (?type_cast: bool, ?trim_empty_rows: bool?, ?pad_empty_rows: bool?, ?pad_empty_cells: bool?) -> Enumerator[Array[untyped], void]
|
|
68
197
|
|
|
69
198
|
# Iterate over all cells across rows.
|
|
70
199
|
#
|
|
@@ -77,12 +206,89 @@ module Xlsxrb
|
|
|
77
206
|
def each_cell: () { (Elements::Cell) -> void } -> void
|
|
78
207
|
| () -> Enumerator[Elements::Cell, void]
|
|
79
208
|
|
|
209
|
+
# Returns all images anchored at a specific cell reference or 0-based coordinate.
|
|
210
|
+
#
|
|
211
|
+
# @param ref_or_row [String, Symbol, Integer] Cell reference (e.g. "A1") or 0-based row index.
|
|
212
|
+
# @param col [Integer, nil] Optional 0-based column index.
|
|
213
|
+
# @return [Array<Elements::Image>]
|
|
214
|
+
# @api public
|
|
215
|
+
# : (String | Symbol | Integer ref_or_row, ?Integer? col) -> Array[Elements::Image]
|
|
216
|
+
def images_at: (String | Symbol | Integer ref_or_row, ?Integer? col) -> Array[Elements::Image]
|
|
217
|
+
|
|
218
|
+
# Yields self with images loaded or returns self.
|
|
219
|
+
#
|
|
220
|
+
# @yield [sheet]
|
|
221
|
+
# @yieldparam sheet [Elements::Worksheet]
|
|
222
|
+
# @return [Elements::Worksheet, void]
|
|
223
|
+
# @api public
|
|
224
|
+
# : () { (Elements::Worksheet) -> void } -> void
|
|
225
|
+
# : () -> Elements::Worksheet
|
|
226
|
+
def with_images: () { (Elements::Worksheet) -> void } -> void
|
|
227
|
+
| () -> Elements::Worksheet
|
|
228
|
+
|
|
80
229
|
# Returns whether the worksheet is valid according to OOXML specifications.
|
|
81
230
|
#
|
|
82
231
|
# @return [Boolean]
|
|
83
232
|
# : () -> bool
|
|
84
233
|
def valid?: () -> bool
|
|
85
234
|
|
|
235
|
+
# Returns whether the worksheet is hidden (:hidden or :very_hidden).
|
|
236
|
+
#
|
|
237
|
+
# @return [Boolean]
|
|
238
|
+
# @api public
|
|
239
|
+
# : () -> bool
|
|
240
|
+
def hidden?: () -> bool
|
|
241
|
+
|
|
242
|
+
# Returns whether the worksheet is visible.
|
|
243
|
+
#
|
|
244
|
+
# @return [Boolean]
|
|
245
|
+
# @api public
|
|
246
|
+
# : () -> bool
|
|
247
|
+
def visible?: () -> bool
|
|
248
|
+
|
|
249
|
+
# Returns hyperlink metadata for the given cell reference, or nil.
|
|
250
|
+
#
|
|
251
|
+
# @param ref_or_row [String, Symbol, Integer] Cell reference (e.g. "A1") or 0-based row index.
|
|
252
|
+
# @param col [Integer, nil] Optional 0-based column index if ref_or_row is a row index.
|
|
253
|
+
# @return [Hash, nil]
|
|
254
|
+
# @api public
|
|
255
|
+
# : (String | Symbol | Integer ref_or_row, ?Integer? col) -> Hash[Symbol, untyped]?
|
|
256
|
+
def hyperlink: (String | Symbol | Integer ref_or_row, ?Integer? col) -> Hash[Symbol, untyped]?
|
|
257
|
+
|
|
258
|
+
# Returns comment metadata for the given cell reference, or nil.
|
|
259
|
+
#
|
|
260
|
+
# @param ref_or_row [String, Symbol, Integer] Cell reference (e.g. "A1") or 0-based row index.
|
|
261
|
+
# @param col [Integer, nil] Optional 0-based column index if ref_or_row is a row index.
|
|
262
|
+
# @return [Hash, nil]
|
|
263
|
+
# @api public
|
|
264
|
+
# : (String | Symbol | Integer ref_or_row, ?Integer? col) -> Hash[Symbol, untyped]?
|
|
265
|
+
def comment: (String | Symbol | Integer ref_or_row, ?Integer? col) -> Hash[Symbol, untyped]?
|
|
266
|
+
|
|
267
|
+
# Returns comments indexed by cell reference.
|
|
268
|
+
#
|
|
269
|
+
# @return [Hash<String, Hash[Symbol, untyped]>]
|
|
270
|
+
# @api public
|
|
271
|
+
# : () -> Hash[String, Hash[Symbol, untyped]]
|
|
272
|
+
def comments_by_ref: () -> Hash[String, Hash[Symbol, untyped]]
|
|
273
|
+
|
|
274
|
+
# Access a cell by reference or 0-based coordinates.
|
|
275
|
+
#
|
|
276
|
+
# @param ref_or_row [String, Symbol, Integer] Cell reference (e.g. "A1") or 0-based row index.
|
|
277
|
+
# @param col [Integer, nil] Optional 0-based column index.
|
|
278
|
+
# @return [Elements::Cell, nil]
|
|
279
|
+
# @api public
|
|
280
|
+
# : (String | Symbol | Integer ref_or_row, ?Integer? col) -> Elements::Cell?
|
|
281
|
+
def cell: (String | Symbol | Integer ref_or_row, ?Integer? col) -> Elements::Cell?
|
|
282
|
+
|
|
283
|
+
# Returns the formatted string representation of a cell's value.
|
|
284
|
+
#
|
|
285
|
+
# @param ref_or_row [String, Symbol, Integer] Cell reference (e.g. "A1") or 0-based row index.
|
|
286
|
+
# @param col [Integer, nil] Optional 0-based column index.
|
|
287
|
+
# @return [String, nil]
|
|
288
|
+
# @api public
|
|
289
|
+
# : (String | Symbol | Integer ref_or_row, ?Integer? col) -> String?
|
|
290
|
+
def formatted_value: (String | Symbol | Integer ref_or_row, ?Integer? col) -> String?
|
|
291
|
+
|
|
86
292
|
# Returns a new Worksheet with the specified cell updated.
|
|
87
293
|
#
|
|
88
294
|
# @example
|
|
@@ -92,10 +298,12 @@ module Xlsxrb
|
|
|
92
298
|
# @param value [Object] The new cell value.
|
|
93
299
|
# @param style_index [Integer, String, nil] Optional new style index.
|
|
94
300
|
# @param formula [Elements::Formula, nil] Optional new formula.
|
|
301
|
+
# @param hyperlink [Hash, String, nil] Optional new hyperlink.
|
|
302
|
+
# @param comment [Hash, String, nil] Optional new comment.
|
|
95
303
|
# @return [Worksheet] A new Worksheet instance.
|
|
96
304
|
# @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
|
|
305
|
+
# : (String ref, ?value: untyped, ?style_index: Integer | String | nil, ?formula: Elements::Formula?, ?hyperlink: (Hash[Symbol, untyped] | String)?, ?comment: (Hash[Symbol, untyped] | String)?) -> Elements::Worksheet
|
|
306
|
+
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
307
|
|
|
100
308
|
# Returns a new Worksheet with attributes replaced (Data-like behavior).
|
|
101
309
|
#
|
|
@@ -143,6 +351,11 @@ module Xlsxrb
|
|
|
143
351
|
# @return [Array<String>] List of errors.
|
|
144
352
|
# : (untyped name, untyped rows) -> Array[String]
|
|
145
353
|
def self.validate: (untyped name, untyped rows) -> Array[String]
|
|
354
|
+
|
|
355
|
+
private
|
|
356
|
+
|
|
357
|
+
# : () -> String?
|
|
358
|
+
def compute_dimension: () -> String?
|
|
146
359
|
end
|
|
147
360
|
end
|
|
148
361
|
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
|
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
module Xlsxrb
|
|
4
4
|
module Ooxml
|
|
5
5
|
# SAX-based parser for xl/styles.xml.
|
|
6
|
-
# Returns
|
|
6
|
+
# Returns an Elements::Styles (Hash) with :num_fmts, :fonts, :fills, :borders, :cell_xfs, :cell_style_xfs.
|
|
7
7
|
class StylesParser
|
|
8
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
26
|
+
def characters: (untyped text) -> untyped
|
|
21
27
|
|
|
22
|
-
def
|
|
28
|
+
def end_element: (untyped _uri, untyped localname, untyped _qname) -> untyped
|
|
23
29
|
end
|
|
24
30
|
end
|
|
25
31
|
|
|
@@ -10,20 +10,32 @@ module Xlsxrb
|
|
|
10
10
|
|
|
11
11
|
EMPTY_HASH: untyped
|
|
12
12
|
|
|
13
|
+
TAG_DELIM_BYTES: untyped
|
|
14
|
+
|
|
15
|
+
ROW_ATTR_START_BYTES: untyped
|
|
16
|
+
|
|
13
17
|
# Parses all rows from a worksheet XML string.
|
|
14
18
|
# Returns an Array of raw row hashes:
|
|
15
19
|
# { index:, cells: [{ ref:, type:, style_index:, value:, formula: }], attrs:, unmapped: }
|
|
16
|
-
def self.parse: (untyped xml_string, ?shared_strings: untyped) -> untyped
|
|
20
|
+
def self.parse: (untyped xml_string, ?shared_strings: untyped, ?styles: untyped) -> untyped
|
|
17
21
|
|
|
18
22
|
# Streaming parse: yields one raw row hash at a time.
|
|
19
|
-
def self.each_row: (untyped xml_source, ?shared_strings: untyped, ?part_name: untyped) ?{ (?) -> untyped } -> untyped
|
|
23
|
+
def self.each_row: (untyped xml_source, ?shared_strings: untyped, ?part_name: untyped, ?styles: untyped, ?date1904: untyped, ?trim_empty_rows: untyped, ?pad_empty_rows: untyped, ?pad_empty_cells: untyped) ?{ (?) -> untyped } -> untyped
|
|
20
24
|
|
|
21
25
|
# Parses column definitions (<cols>) from a worksheet.
|
|
22
|
-
def self.parse_columns: (untyped xml_string, ?
|
|
26
|
+
def self.parse_columns: (untyped xml_string, ?untyped _part_name) -> untyped
|
|
23
27
|
|
|
24
28
|
# Yields Event objects for columns, rows, cells, and hyperlinks.
|
|
25
29
|
def self.each_event: (untyped xml_string, ?shared_strings: untyped, ?part_name: untyped) ?{ (?) -> untyped } -> untyped
|
|
26
30
|
|
|
31
|
+
# Parses all hyperlink elements from worksheet XML.
|
|
32
|
+
#
|
|
33
|
+
# @param xml_string [String, nil]
|
|
34
|
+
# @return [Array<Hash[Symbol, untyped]>]
|
|
35
|
+
# @api public
|
|
36
|
+
# : (String?) -> Array[Hash[Symbol, untyped]]
|
|
37
|
+
def self.parse_hyperlinks: (String?) -> Array[Hash[Symbol, untyped]]
|
|
38
|
+
|
|
27
39
|
def self.fast_scan_events: (untyped xml_src, untyped shared_strings, untyped part_name) ?{ (?) -> untyped } -> untyped
|
|
28
40
|
|
|
29
41
|
def self.extract_row_attrs: (untyped row_tag) -> untyped
|
|
@@ -43,6 +55,9 @@ module Xlsxrb
|
|
|
43
55
|
# : (String str) -> String
|
|
44
56
|
def self.decode_xml_entities: (String str) -> String
|
|
45
57
|
|
|
58
|
+
# : (String str) -> String
|
|
59
|
+
def self.normalize_text: (String str) -> String
|
|
60
|
+
|
|
46
61
|
# Parses <cols> section for column definitions.
|
|
47
62
|
class ColumnsListener
|
|
48
63
|
include REXML::SAX2Listener
|
|
@@ -58,9 +73,11 @@ module Xlsxrb
|
|
|
58
73
|
def characters: (untyped _text) -> untyped
|
|
59
74
|
end
|
|
60
75
|
|
|
61
|
-
|
|
76
|
+
# rubocop:disable Style/OptionalBooleanParameter
|
|
77
|
+
def self.fast_scan_rows_direct: (untyped xml_src, untyped shared_strings, untyped _part_name, ?untyped styles, ?untyped date1904, ?untyped pad_empty_cells) ?{ (?) -> untyped } -> untyped
|
|
62
78
|
|
|
63
|
-
|
|
79
|
+
# rubocop:disable Style/OptionalBooleanParameter
|
|
80
|
+
def self.scan_rows_stream: (untyped source, untyped shared_strings, untyped _part_name, ?untyped styles, ?untyped date1904, ?untyped pad_empty_cells) ?{ (?) -> untyped } -> untyped
|
|
64
81
|
|
|
65
82
|
COL_LETTERS: untyped
|
|
66
83
|
|
|
@@ -78,7 +95,12 @@ module Xlsxrb
|
|
|
78
95
|
|
|
79
96
|
def self.fast_parse_cells_direct: (untyped xml, untyped from, untyped to, untyped shared_strings, untyped row_source, ?untyped prefix) -> untyped
|
|
80
97
|
|
|
81
|
-
|
|
98
|
+
# rubocop:disable Style/OptionalBooleanParameter
|
|
99
|
+
def self.fast_scan_cells_direct: (untyped xml, untyped from, untyped to, untyped shared_strings, untyped row_source, ?untyped _prefix, ?untyped styles, ?untyped date1904) ?{ (?) -> untyped } -> untyped
|
|
100
|
+
|
|
101
|
+
# rubocop:disable Style/OptionalBooleanParameter
|
|
102
|
+
# : (String xml, Integer from, Integer to, Array[String] shared_strings, ?untyped styles, ?bool date1904, ?type_cast: bool) -> Array[untyped]
|
|
103
|
+
def self.fast_scan_row_values: (String xml, Integer from, Integer to, Array[String] shared_strings, ?untyped styles, ?bool date1904, ?type_cast: bool) -> Array[untyped]
|
|
82
104
|
end
|
|
83
105
|
end
|
|
84
106
|
end
|
|
@@ -13,7 +13,9 @@ module Xlsxrb
|
|
|
13
13
|
|
|
14
14
|
INTEGER_STRINGS: untyped
|
|
15
15
|
|
|
16
|
-
def initialize: (untyped io) -> untyped
|
|
16
|
+
def initialize: (untyped io, ?date1904: untyped) -> untyped
|
|
17
|
+
|
|
18
|
+
def set_column_style: (untyped col_index, untyped style_id) -> untyped
|
|
17
19
|
|
|
18
20
|
# Write the worksheet header. Call once before writing rows.
|
|
19
21
|
# Options for pre-sheetData elements:
|
|
@@ -432,6 +432,8 @@ module Xlsxrb
|
|
|
432
432
|
# : (untyped name, untyped value) -> untyped
|
|
433
433
|
def set_workbook_property: (untyped name, untyped value) -> untyped
|
|
434
434
|
|
|
435
|
+
alias workbook_property set_workbook_property
|
|
436
|
+
|
|
435
437
|
# Returns workbook properties hash.
|
|
436
438
|
# : () -> untyped
|
|
437
439
|
def workbook_properties: () -> untyped
|