xlsxrb 0.2.0 → 0.2.1
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 +37 -0
- data/README.md +1 -1
- data/lib/xlsxrb/dsl_helpers.rb +49 -1
- data/lib/xlsxrb/elements/worksheet.rb +2 -2
- data/lib/xlsxrb/ooxml/utils.rb +13 -0
- data/lib/xlsxrb/ooxml/workbook_writer.rb +13 -2
- data/lib/xlsxrb/ooxml/worksheet_writer.rb +302 -228
- data/lib/xlsxrb/ooxml/writer/features_xml.rb +11 -4
- data/lib/xlsxrb/ooxml/writer.rb +1 -1
- data/lib/xlsxrb/ooxml/xml_builder.rb +18 -0
- data/lib/xlsxrb/stream_row.rb +2 -2
- data/lib/xlsxrb/stream_writer.rb +203 -80
- data/lib/xlsxrb/style_builder.rb +339 -0
- data/lib/xlsxrb/version.rb +1 -1
- data/lib/xlsxrb/workbook_builder.rb +239 -88
- data/lib/xlsxrb/worksheet_builder.rb +841 -134
- data/lib/xlsxrb.rb +19 -0
- data/sig/generated/xlsxrb/dsl_helpers.rbs +28 -0
- data/sig/generated/xlsxrb/ooxml/utils.rbs +10 -0
- data/sig/generated/xlsxrb/ooxml/workbook_writer.rbs +5 -0
- data/sig/generated/xlsxrb/ooxml/worksheet_writer.rbs +53 -0
- data/sig/generated/xlsxrb/ooxml/writer/features_xml.rbs +3 -0
- data/sig/generated/xlsxrb/ooxml/xml_builder.rbs +12 -0
- data/sig/generated/xlsxrb/stream_row.rbs +2 -2
- data/sig/generated/xlsxrb/stream_writer.rbs +40 -4
- data/sig/generated/xlsxrb/style_builder.rbs +261 -0
- data/sig/generated/xlsxrb/workbook_builder.rbs +42 -9
- data/sig/generated/xlsxrb/worksheet_builder.rbs +615 -3
- data/sig/generated/xlsxrb.rbs +15 -0
- metadata +1 -1
|
@@ -12,9 +12,12 @@ module Xlsxrb
|
|
|
12
12
|
# @param name [String] The worksheet name.
|
|
13
13
|
# @param strict_excel_mode [Boolean] Whether to enforce Microsoft Excel limits.
|
|
14
14
|
# @param state [Symbol] Sheet visibility state (:visible, :hidden, or :very_hidden).
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
# @param style_log [StyleLog] When the workbook's styles are defined (internal).
|
|
16
|
+
#: (String name, ?strict_excel_mode: bool, ?state: Symbol, ?style_log: StyleLog) -> void
|
|
17
|
+
def initialize(name, strict_excel_mode: true, state: :visible, style_log: StyleLog.new)
|
|
17
18
|
@name = name
|
|
19
|
+
@style_log = style_log
|
|
20
|
+
@column_style_clocks = {} # { column index => style log clock when its style was set }
|
|
18
21
|
@strict_excel_mode = strict_excel_mode
|
|
19
22
|
@state = state ? state.to_sym : :visible
|
|
20
23
|
@next_row_index = 0
|
|
@@ -80,6 +83,8 @@ module Xlsxrb
|
|
|
80
83
|
# @yield [style_builder]
|
|
81
84
|
# @yieldparam style_builder [Xlsxrb::StyleBuilder]
|
|
82
85
|
# @return [StyleBuilder]
|
|
86
|
+
# Using the returned value is deprecated and warns; in version 0.3.0, this method
|
|
87
|
+
# will return nil. Configure the style with options or in the block.
|
|
83
88
|
# @api public
|
|
84
89
|
#: (String | Symbol name, **untyped opts) ?{ (StyleBuilder) -> void } -> StyleBuilder
|
|
85
90
|
def style(name, **opts)
|
|
@@ -88,7 +93,8 @@ module Xlsxrb
|
|
|
88
93
|
style_builder.apply_options!(**opts) unless opts.empty?
|
|
89
94
|
yield style_builder if block_given?
|
|
90
95
|
@styles[style_name] = style_builder
|
|
91
|
-
style_builder
|
|
96
|
+
@style_log.record(style_name, style_builder)
|
|
97
|
+
ReturnedStyleBuilder.new(style_builder)
|
|
92
98
|
end
|
|
93
99
|
|
|
94
100
|
# Creates an {Elements::Formula} object.
|
|
@@ -147,6 +153,7 @@ module Xlsxrb
|
|
|
147
153
|
# @api public
|
|
148
154
|
#: (Array[untyped] | Hash[untyped, untyped] values, ?cell_styles: untyped, ?row_style: (Integer | Symbol | String | Hash[Symbol, untyped])?, ?height: Float | Integer | nil, ?hidden: bool, ?custom_height: bool, ?collapsed: bool, ?outline_level: Integer | nil) -> void
|
|
149
155
|
def row(values, cell_styles: nil, row_style: nil, height: nil, hidden: false, custom_height: false, collapsed: false, outline_level: nil)
|
|
156
|
+
check_open!
|
|
150
157
|
row_index = @next_row_index
|
|
151
158
|
DslHelpers.validate_row_bounds!(row_index, height, strict_excel_mode: @strict_excel_mode)
|
|
152
159
|
@next_row_index += 1
|
|
@@ -159,22 +166,52 @@ module Xlsxrb
|
|
|
159
166
|
|
|
160
167
|
values = DslHelpers.normalize_row_values(values)
|
|
161
168
|
cell_styles = DslHelpers.normalize_row_styles(cell_styles)
|
|
169
|
+
# The row is kept as given until the workbook resolves its styles, so it must not
|
|
170
|
+
# change with the caller's arrays. Each array is copied once, when first needed.
|
|
171
|
+
values_copied = false
|
|
172
|
+
styles_copied = false
|
|
162
173
|
|
|
163
174
|
# Auto-detect Date / Time for built-in styles
|
|
164
175
|
values.each_with_index do |val, idx|
|
|
165
176
|
cell_style = cell_styles.is_a?(Array) ? cell_styles[idx] : cell_styles
|
|
166
177
|
|
|
167
178
|
if val.is_a?(Date) && !val.is_a?(DateTime) && cell_style.nil?
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
179
|
+
auto_style = inherited_date_style(row_style, idx)
|
|
180
|
+
unless auto_style
|
|
181
|
+
style("__xlsxrb_date", number_format: "yyyy-mm-dd") unless @styles.key?("__xlsxrb_date")
|
|
182
|
+
auto_style = "__xlsxrb_date"
|
|
183
|
+
end
|
|
184
|
+
elsif val.is_a?(Time) || val.is_a?(DateTime)
|
|
185
|
+
# A value that claims to be a Time without being one, such as
|
|
186
|
+
# ActiveSupport::TimeWithZone, is kept as a Time with the same wall clock.
|
|
187
|
+
unless Time === val || val.is_a?(DateTime) # rubocop:disable Style/CaseEquality
|
|
188
|
+
unless values_copied
|
|
189
|
+
values = values.dup
|
|
190
|
+
values_copied = true
|
|
191
|
+
end
|
|
192
|
+
values[idx] = Ooxml::WorksheetWriter::TimeLike.to_time(val)
|
|
193
|
+
end
|
|
194
|
+
next unless cell_style.nil?
|
|
195
|
+
|
|
196
|
+
auto_style = inherited_date_style(row_style, idx)
|
|
197
|
+
unless auto_style
|
|
198
|
+
style("__xlsxrb_time", number_format: "yyyy-mm-dd hh:mm:ss") unless @styles.key?("__xlsxrb_time")
|
|
199
|
+
auto_style = "__xlsxrb_time"
|
|
200
|
+
end
|
|
201
|
+
else
|
|
202
|
+
next
|
|
177
203
|
end
|
|
204
|
+
unless styles_copied
|
|
205
|
+
cell_styles = if cell_styles.nil?
|
|
206
|
+
[]
|
|
207
|
+
elsif cell_styles.is_a?(Array)
|
|
208
|
+
cell_styles.dup
|
|
209
|
+
else
|
|
210
|
+
Array.new(values.size, cell_styles)
|
|
211
|
+
end
|
|
212
|
+
styles_copied = true
|
|
213
|
+
end
|
|
214
|
+
cell_styles[idx] = auto_style
|
|
178
215
|
end
|
|
179
216
|
|
|
180
217
|
max_len = values.size
|
|
@@ -182,103 +219,66 @@ module Xlsxrb
|
|
|
182
219
|
# See: https://support.microsoft.com/en-us/office/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3
|
|
183
220
|
raise ArgumentError, "Row contains #{max_len} columns, exceeding Excel limit of 16_384 columns" if @strict_excel_mode && max_len > 16_384
|
|
184
221
|
|
|
185
|
-
cells = Array.new(max_len)
|
|
186
222
|
style_lookup = cell_styles.is_a?(Array)
|
|
223
|
+
# Number format codes of the cells' sheet styles, as of this call.
|
|
224
|
+
format_codes = style_lookup ? nil : format_code_of(cell_styles)
|
|
187
225
|
|
|
188
226
|
col_index = 0
|
|
189
227
|
while col_index < max_len
|
|
190
228
|
val = col_index < values.size ? values[col_index] : nil
|
|
191
229
|
raise ArgumentError, "Invalid cell value type or value: #{val.class} for value #{val.inspect}" unless val.nil? || val.is_a?(String) || (val.is_a?(Numeric) && !(val.is_a?(Float) && (val.infinite? || val.nan?))) || val.is_a?(TrueClass) || val.is_a?(FalseClass) || val.is_a?(Date) || val.is_a?(Time) || val.is_a?(Elements::Formula) || (val.is_a?(Hash) && val.key?(:formula)) || val.is_a?(Elements::RichText) || val.is_a?(Elements::CellError) || (val.is_a?(Array) && val.first.is_a?(Hash) && (val.first.key?(:text) || val.first.key?("text")))
|
|
230
|
+
|
|
192
231
|
# See: https://support.microsoft.com/en-us/office/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
if val.is_a?(Array)
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
font = run.reject { |k| k.to_s == "text" }
|
|
200
|
-
{ text: text, font: font.empty? ? nil : font }.compact
|
|
232
|
+
DslHelpers.check_cell_text_length!(val) if @strict_excel_mode && val.is_a?(String) && val.bytesize > DslHelpers::MAX_CELL_TEXT_LENGTH
|
|
233
|
+
|
|
234
|
+
if val.is_a?(Array) || val.is_a?(Hash)
|
|
235
|
+
unless values_copied
|
|
236
|
+
values = values.dup
|
|
237
|
+
values_copied = true
|
|
201
238
|
end
|
|
202
|
-
|
|
239
|
+
values[col_index] = if val.is_a?(Array)
|
|
240
|
+
# Coerce array of hashes to RichText
|
|
241
|
+
runs = val.map do |run|
|
|
242
|
+
text = run[:text] || run["text"]
|
|
243
|
+
font = run.reject { |k| k.to_s == "text" }
|
|
244
|
+
{ text: text, font: font.empty? ? nil : font }.compact
|
|
245
|
+
end
|
|
246
|
+
Elements::RichText.new(runs: runs)
|
|
247
|
+
else
|
|
248
|
+
# A Hash with :formula becomes the cell's formula.
|
|
249
|
+
Elements::Formula.new(
|
|
250
|
+
expression: val[:formula] || val[:expression] || "",
|
|
251
|
+
cached_value: val.key?(:value) ? val[:value] : val[:cached_value],
|
|
252
|
+
type: val[:type] || (:shared if val.key?(:shared_index)),
|
|
253
|
+
ref: val[:ref],
|
|
254
|
+
shared_index: val[:shared_index],
|
|
255
|
+
calculate_always: val[:calculate_always]
|
|
256
|
+
)
|
|
257
|
+
end
|
|
203
258
|
end
|
|
204
259
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
col_index
|
|
218
|
-
next
|
|
260
|
+
if style_lookup
|
|
261
|
+
style_name = col_index < cell_styles.size ? cell_styles[col_index] : nil
|
|
262
|
+
if style_name.is_a?(Hash)
|
|
263
|
+
inline_name = "__inline_#{style_name.hash}"
|
|
264
|
+
style(inline_name, **style_name) unless @styles.key?(inline_name)
|
|
265
|
+
unless styles_copied
|
|
266
|
+
cell_styles = cell_styles.dup
|
|
267
|
+
styles_copied = true
|
|
268
|
+
end
|
|
269
|
+
cell_styles[col_index] = style_name = inline_name
|
|
270
|
+
end
|
|
271
|
+
format_code = style_name.nil? ? nil : format_code_of(style_name)
|
|
272
|
+
(format_codes ||= [])[col_index] = format_code if format_code
|
|
219
273
|
end
|
|
220
|
-
sb = @styles[style_name]
|
|
221
|
-
fmt_code = if sb&.number_format
|
|
222
|
-
sb.number_format.is_a?(String) ? sb.number_format : Ooxml::Utils::BUILTIN_NUM_FMT_CODES[sb.number_format]
|
|
223
|
-
end
|
|
224
|
-
# If value is a Formula object or Hash with :formula, store it as the cell's formula
|
|
225
|
-
cells[col_index] = if val.is_a?(Elements::Formula)
|
|
226
|
-
Elements::Cell.new(
|
|
227
|
-
row_index: row_index,
|
|
228
|
-
column_index: col_index,
|
|
229
|
-
value: val.cached_value,
|
|
230
|
-
formula: val,
|
|
231
|
-
style: style_name,
|
|
232
|
-
raw_value: val.cached_value&.to_s,
|
|
233
|
-
format_code: fmt_code
|
|
234
|
-
)
|
|
235
|
-
elsif val.is_a?(Hash) && (val.key?(:formula) || val.key?(:expression) || (val[:type]&.to_sym == :shared && val.key?(:shared_index)))
|
|
236
|
-
cached_val = val.key?(:value) ? val[:value] : val[:cached_value]
|
|
237
|
-
f_expr = val[:formula] || val[:expression] || ""
|
|
238
|
-
f_type = val[:type] || (:shared if val.key?(:shared_index))
|
|
239
|
-
f_obj = Elements::Formula.new(
|
|
240
|
-
expression: f_expr,
|
|
241
|
-
cached_value: cached_val,
|
|
242
|
-
type: f_type,
|
|
243
|
-
ref: val[:ref],
|
|
244
|
-
shared_index: val[:shared_index],
|
|
245
|
-
calculate_always: val[:calculate_always]
|
|
246
|
-
)
|
|
247
|
-
Elements::Cell.new(
|
|
248
|
-
row_index: row_index,
|
|
249
|
-
column_index: col_index,
|
|
250
|
-
value: cached_val,
|
|
251
|
-
formula: f_obj,
|
|
252
|
-
style: style_name,
|
|
253
|
-
raw_value: cached_val&.to_s,
|
|
254
|
-
format_code: fmt_code
|
|
255
|
-
)
|
|
256
|
-
else
|
|
257
|
-
Elements::Cell.new(
|
|
258
|
-
row_index: row_index,
|
|
259
|
-
column_index: col_index,
|
|
260
|
-
value: val,
|
|
261
|
-
style: style_name,
|
|
262
|
-
raw_value: val&.to_s,
|
|
263
|
-
format_code: fmt_code
|
|
264
|
-
)
|
|
265
|
-
end
|
|
266
274
|
col_index += 1
|
|
267
275
|
end
|
|
268
276
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
@rows <<
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
height: height,
|
|
275
|
-
hidden: hidden,
|
|
276
|
-
custom_height: custom_height || !height.nil?,
|
|
277
|
-
collapsed: collapsed,
|
|
278
|
-
outline_level: outline_level,
|
|
279
|
-
style_index: row_style,
|
|
280
|
-
unmapped_data: unmapped
|
|
281
|
-
)
|
|
277
|
+
values = values.dup unless values_copied || values.frozen?
|
|
278
|
+
cell_styles = cell_styles.dup if style_lookup && !styles_copied && !cell_styles.frozen?
|
|
279
|
+
@rows << PendingRow.new(row_index, values, cell_styles, format_codes, max_len, height, hidden,
|
|
280
|
+
custom_height || !height.nil?, collapsed, outline_level, row_style, @style_log.clock)
|
|
281
|
+
nil
|
|
282
282
|
end
|
|
283
283
|
|
|
284
284
|
# Appends a row to the worksheet and returns self for chaining.
|
|
@@ -305,9 +305,11 @@ module Xlsxrb
|
|
|
305
305
|
# @api public
|
|
306
306
|
#: (?Integer count) -> void
|
|
307
307
|
def skip_rows(count = 1)
|
|
308
|
+
check_open!
|
|
308
309
|
raise ArgumentError, "count must be positive: #{count.inspect}" if !count.is_a?(Integer) || count < 1
|
|
309
310
|
|
|
310
311
|
@next_row_index += count
|
|
312
|
+
nil
|
|
311
313
|
end
|
|
312
314
|
|
|
313
315
|
# Sets column formatting and properties for one or multiple columns.
|
|
@@ -330,6 +332,7 @@ module Xlsxrb
|
|
|
330
332
|
raise ArgumentError, "Column width #{width} must be between 0 and 255 characters (Excel limitation)" if @strict_excel_mode && width && (width.negative? || width > 255)
|
|
331
333
|
|
|
332
334
|
DslHelpers.normalize_column_indices(index).each do |idx|
|
|
335
|
+
@column_style_clocks[idx] = @style_log.clock unless style.nil?
|
|
333
336
|
existing_idx = @columns.find_index { |c| c.index == idx }
|
|
334
337
|
if existing_idx
|
|
335
338
|
prev = @columns[existing_idx]
|
|
@@ -440,26 +443,22 @@ module Xlsxrb
|
|
|
440
443
|
when Array then rows
|
|
441
444
|
else [rows.to_i]
|
|
442
445
|
end
|
|
446
|
+
check_open!
|
|
443
447
|
row_indices.each do |idx|
|
|
444
448
|
existing_row = @rows.find { |r| r.index == idx }
|
|
445
449
|
if existing_row
|
|
446
450
|
existing_idx = @rows.index(existing_row)
|
|
447
|
-
@rows[existing_idx] =
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
hidden: hidden || existing_row.hidden?,
|
|
452
|
-
custom_height: existing_row.custom_height?,
|
|
453
|
-
collapsed: collapsed || existing_row.collapsed?,
|
|
454
|
-
outline_level: level,
|
|
455
|
-
style_index: existing_row.style_index,
|
|
456
|
-
unmapped_data: existing_row.unmapped_data
|
|
451
|
+
@rows[existing_idx] = existing_row.with_outline(
|
|
452
|
+
hidden: hidden || existing_row.hidden,
|
|
453
|
+
collapsed: collapsed || existing_row.collapsed,
|
|
454
|
+
outline_level: level
|
|
457
455
|
)
|
|
458
456
|
else
|
|
459
457
|
@pending_row_attributes[idx] = { outline_level: level, collapsed: collapsed, hidden: hidden }
|
|
460
458
|
end
|
|
461
459
|
end
|
|
462
460
|
end
|
|
461
|
+
nil
|
|
463
462
|
end
|
|
464
463
|
|
|
465
464
|
# Configures or queries worksheet-level outline and grouping view properties.
|
|
@@ -1680,12 +1679,68 @@ module Xlsxrb
|
|
|
1680
1679
|
spec
|
|
1681
1680
|
end
|
|
1682
1681
|
|
|
1683
|
-
# Builds and returns the in-memory {Elements::Worksheet}.
|
|
1682
|
+
# Builds and returns the in-memory {Elements::Worksheet}. Cells carry their style
|
|
1683
|
+
# names; {WorkbookBuilder#build} resolves them to style indexes.
|
|
1684
1684
|
#
|
|
1685
|
+
# @deprecated Read the sheet from the workbook that {Xlsxrb.build} returns. This
|
|
1686
|
+
# method will be private in version 0.3.0.
|
|
1685
1687
|
# @return [Elements::Worksheet]
|
|
1686
1688
|
# @api public
|
|
1687
1689
|
#: () -> Elements::Worksheet
|
|
1688
1690
|
def build
|
|
1691
|
+
Deprecation.warn("WorksheetBuilder#build is deprecated; read the sheet from the workbook that Xlsxrb.build returns. It will be private in version 0.3.0.")
|
|
1692
|
+
snapshot(@rows.dup.freeze).worksheet
|
|
1693
|
+
end
|
|
1694
|
+
|
|
1695
|
+
# Ends the sheet block: rows can no longer be added, and the sheet's state is taken
|
|
1696
|
+
# as it is now.
|
|
1697
|
+
#
|
|
1698
|
+
# @return [Snapshot]
|
|
1699
|
+
# @api private
|
|
1700
|
+
#: () -> Snapshot
|
|
1701
|
+
def close
|
|
1702
|
+
@closed = true
|
|
1703
|
+
snapshot(@rows.freeze)
|
|
1704
|
+
end
|
|
1705
|
+
|
|
1706
|
+
# Internal: returns styles for later processing by WorkbookBuilder
|
|
1707
|
+
# @return [Hash{String => StyleBuilder}]
|
|
1708
|
+
#: Hash[String, StyleBuilder]
|
|
1709
|
+
attr_reader :styles
|
|
1710
|
+
|
|
1711
|
+
private
|
|
1712
|
+
|
|
1713
|
+
#: () -> void
|
|
1714
|
+
def check_open!
|
|
1715
|
+
raise Error, "Sheet '#{@name}' is closed: add its rows inside its sheet block" if @closed
|
|
1716
|
+
end
|
|
1717
|
+
|
|
1718
|
+
# The style that a Date or Time cell without a cell style inherits, to give the cell
|
|
1719
|
+
# in its place: the row style, or the sheet's column style in a row without one. The
|
|
1720
|
+
# workbook then gives the cell a variant of that style with the default date or
|
|
1721
|
+
# date-time format, so it keeps the style's font, fill, and border, as StreamWriter
|
|
1722
|
+
# does. Returns nil for a style index or for no style.
|
|
1723
|
+
#: (untyped row_style, Integer column_index) -> (String | Symbol | Hash[Symbol, untyped])?
|
|
1724
|
+
def inherited_date_style(row_style, column_index)
|
|
1725
|
+
style = if !row_style.nil?
|
|
1726
|
+
row_style
|
|
1727
|
+
elsif @column_style_clocks.key?(column_index)
|
|
1728
|
+
@columns.find { |column| column.index == column_index }&.style_index
|
|
1729
|
+
end
|
|
1730
|
+
style if style.is_a?(String) || style.is_a?(Symbol) || style.is_a?(Hash)
|
|
1731
|
+
end
|
|
1732
|
+
|
|
1733
|
+
# Returns the number format code of the sheet style named +style_name+, if it has one.
|
|
1734
|
+
#: (untyped style_name) -> String?
|
|
1735
|
+
def format_code_of(style_name)
|
|
1736
|
+
number_format = @styles[style_name]&.number_format
|
|
1737
|
+
return nil unless number_format
|
|
1738
|
+
|
|
1739
|
+
number_format.is_a?(String) ? number_format : Ooxml::Utils::BUILTIN_NUM_FMT_CODES[number_format]
|
|
1740
|
+
end
|
|
1741
|
+
|
|
1742
|
+
#: (Array[PendingRow] rows) -> Snapshot
|
|
1743
|
+
def snapshot(rows)
|
|
1689
1744
|
facade_meta = {}
|
|
1690
1745
|
facade_meta[:hyperlinks] = @hyperlinks unless @hyperlinks.empty?
|
|
1691
1746
|
facade_meta[:auto_filter] = @auto_filter if @auto_filter
|
|
@@ -1755,30 +1810,8 @@ module Xlsxrb
|
|
|
1755
1810
|
(tc_hash[ref] ||= []) << obj
|
|
1756
1811
|
end
|
|
1757
1812
|
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
else
|
|
1761
|
-
@rows.map do |row|
|
|
1762
|
-
new_cells = row.cells.map do |cell|
|
|
1763
|
-
hl = hl_hash[cell.ref]
|
|
1764
|
-
cm = cm_hash[cell.ref]
|
|
1765
|
-
tcs = tc_hash[cell.ref]
|
|
1766
|
-
if hl || cm || tcs
|
|
1767
|
-
cell.with(
|
|
1768
|
-
hyperlink: hl || cell.hyperlink,
|
|
1769
|
-
comment: cm || cell.comment,
|
|
1770
|
-
threaded_comments: (tcs ? (cell.threaded_comments + tcs) : cell.threaded_comments)
|
|
1771
|
-
)
|
|
1772
|
-
else
|
|
1773
|
-
cell
|
|
1774
|
-
end
|
|
1775
|
-
end
|
|
1776
|
-
row.with(cells: new_cells)
|
|
1777
|
-
end
|
|
1778
|
-
end
|
|
1779
|
-
|
|
1780
|
-
Elements::Worksheet.new(
|
|
1781
|
-
name: @name, rows: rows, columns: @columns, charts: @charts,
|
|
1813
|
+
frame = Elements::Worksheet.new(
|
|
1814
|
+
name: @name, rows: [], columns: @columns, charts: @charts,
|
|
1782
1815
|
conditional_formats: @conditional_formats,
|
|
1783
1816
|
data_validations: @data_validations,
|
|
1784
1817
|
unmapped_data: facade_meta.empty? ? {} : { facade: facade_meta },
|
|
@@ -1815,12 +1848,686 @@ module Xlsxrb
|
|
|
1815
1848
|
sheet_calc_properties: @sheet_calc_pr,
|
|
1816
1849
|
background_image: @background_image
|
|
1817
1850
|
)
|
|
1851
|
+
Snapshot.new(frame, rows, hl_hash, cm_hash, tc_hash, @column_style_clocks.dup)
|
|
1818
1852
|
end
|
|
1853
|
+
end
|
|
1819
1854
|
|
|
1820
|
-
|
|
1821
|
-
#
|
|
1822
|
-
|
|
1823
|
-
|
|
1855
|
+
class WorksheetBuilder
|
|
1856
|
+
# A row as given to {WorksheetBuilder#row}, kept until the workbook resolves its
|
|
1857
|
+
# style names, so that its cells are created once.
|
|
1858
|
+
#
|
|
1859
|
+
# @api private
|
|
1860
|
+
class PendingRow
|
|
1861
|
+
#: Integer
|
|
1862
|
+
attr_reader :index
|
|
1863
|
+
# Cell values; Hashes with :formula and rich text runs are already converted.
|
|
1864
|
+
#: Array[untyped]
|
|
1865
|
+
attr_reader :values
|
|
1866
|
+
# Style of each cell: a name, an index, or nil; or one of these for every cell.
|
|
1867
|
+
#: untyped
|
|
1868
|
+
attr_reader :styles
|
|
1869
|
+
# Number format codes of the cells' sheet styles: an Array, one code, or nil.
|
|
1870
|
+
#: untyped
|
|
1871
|
+
attr_reader :format_codes
|
|
1872
|
+
# Number of columns the row spans, including styled cells past the last value.
|
|
1873
|
+
#: Integer
|
|
1874
|
+
attr_reader :width
|
|
1875
|
+
#: (Float | Integer)?
|
|
1876
|
+
attr_reader :height
|
|
1877
|
+
#: untyped
|
|
1878
|
+
attr_reader :hidden
|
|
1879
|
+
#: bool
|
|
1880
|
+
attr_reader :custom_height
|
|
1881
|
+
#: untyped
|
|
1882
|
+
attr_reader :collapsed
|
|
1883
|
+
#: Integer?
|
|
1884
|
+
attr_reader :outline_level
|
|
1885
|
+
# The row style as given: a name, an index, an inline Hash, or nil.
|
|
1886
|
+
#: untyped
|
|
1887
|
+
attr_reader :style
|
|
1888
|
+
# The style log clock when the row was added: its styles are the definitions made before.
|
|
1889
|
+
#: Integer
|
|
1890
|
+
attr_reader :clock
|
|
1891
|
+
|
|
1892
|
+
#: (Integer index, Array[untyped] values, untyped styles, untyped format_codes, Integer width, (Float | Integer)? height, untyped hidden, bool custom_height, untyped collapsed, Integer? outline_level, untyped style, Integer clock) -> void
|
|
1893
|
+
def initialize(index, values, styles, format_codes, width, height, hidden, custom_height, collapsed, outline_level, style, clock)
|
|
1894
|
+
@index = index
|
|
1895
|
+
@values = values
|
|
1896
|
+
@styles = styles
|
|
1897
|
+
@format_codes = format_codes
|
|
1898
|
+
@width = width
|
|
1899
|
+
@height = height
|
|
1900
|
+
@hidden = hidden
|
|
1901
|
+
@custom_height = custom_height
|
|
1902
|
+
@collapsed = collapsed
|
|
1903
|
+
@outline_level = outline_level
|
|
1904
|
+
@style = style
|
|
1905
|
+
@clock = clock
|
|
1906
|
+
end
|
|
1907
|
+
|
|
1908
|
+
#: (hidden: untyped, collapsed: untyped, outline_level: Integer?) -> PendingRow
|
|
1909
|
+
def with_outline(hidden:, collapsed:, outline_level:)
|
|
1910
|
+
PendingRow.new(@index, @values, @styles, @format_codes, @width, @height, hidden, @custom_height, collapsed, outline_level, @style, @clock)
|
|
1911
|
+
end
|
|
1912
|
+
|
|
1913
|
+
# Returns whether every cell of the row is within Excel's row and column limits.
|
|
1914
|
+
#: () -> bool
|
|
1915
|
+
def within_limits?
|
|
1916
|
+
Elements::Cell.valid_coordinates?(@index, 0) && @width <= 16_384
|
|
1917
|
+
end
|
|
1918
|
+
|
|
1919
|
+
# Returns the row's cells with their style names, as {WorksheetBuilder#build} gives them.
|
|
1920
|
+
#: () -> Array[Elements::Cell]
|
|
1921
|
+
def named_cells
|
|
1922
|
+
values = @values
|
|
1923
|
+
styles = @styles
|
|
1924
|
+
codes = @format_codes
|
|
1925
|
+
style_lookup = styles.is_a?(Array)
|
|
1926
|
+
code_lookup = codes.is_a?(Array)
|
|
1927
|
+
all_valid = within_limits?
|
|
1928
|
+
cells = [] #: Array[Elements::Cell]
|
|
1929
|
+
col_index = 0
|
|
1930
|
+
while col_index < @width
|
|
1931
|
+
value = col_index < values.size ? values[col_index] : nil
|
|
1932
|
+
style = style_lookup ? styles[col_index] : styles
|
|
1933
|
+
unless value.nil? && style.nil?
|
|
1934
|
+
code = code_lookup ? codes[col_index] : codes
|
|
1935
|
+
cells << PendingRow.cell(@index, col_index, value, style, code, all_valid || Elements::Cell.valid_coordinates?(@index, col_index))
|
|
1936
|
+
end
|
|
1937
|
+
col_index += 1
|
|
1938
|
+
end
|
|
1939
|
+
cells
|
|
1940
|
+
end
|
|
1941
|
+
|
|
1942
|
+
#: (Array[Elements::Cell] cells, untyped style_index) -> Elements::Row
|
|
1943
|
+
def to_row(cells, style_index)
|
|
1944
|
+
Elements::Row.new(
|
|
1945
|
+
index: @index,
|
|
1946
|
+
cells: cells,
|
|
1947
|
+
height: @height,
|
|
1948
|
+
hidden: @hidden,
|
|
1949
|
+
custom_height: @custom_height,
|
|
1950
|
+
collapsed: @collapsed,
|
|
1951
|
+
outline_level: @outline_level,
|
|
1952
|
+
style_index: style_index,
|
|
1953
|
+
unmapped_data: Elements::EMPTY_HASH
|
|
1954
|
+
)
|
|
1955
|
+
end
|
|
1956
|
+
|
|
1957
|
+
# Creates a cell for +value+ with +style+ (a name, an index, or nil).
|
|
1958
|
+
# +valid_coordinates+ tells whether the cell is within Excel's limits; a valid cell
|
|
1959
|
+
# has no errors, so it skips the checks of Cell.new.
|
|
1960
|
+
#: (Integer row_index, Integer column_index, untyped value, untyped style, String? format_code, bool valid_coordinates) -> Elements::Cell
|
|
1961
|
+
def self.cell(row_index, column_index, value, style, format_code, valid_coordinates)
|
|
1962
|
+
formula = nil
|
|
1963
|
+
if value.is_a?(Elements::Formula)
|
|
1964
|
+
formula = value
|
|
1965
|
+
value = formula.cached_value
|
|
1966
|
+
valid_coordinates &&= Elements::Cell.valid_value?(value)
|
|
1967
|
+
end
|
|
1968
|
+
raw_value = value&.to_s
|
|
1969
|
+
if valid_coordinates && !style.is_a?(Integer)
|
|
1970
|
+
Elements::Cell.fast_create(row_index, column_index, value, style, formula, raw_value, format_code)
|
|
1971
|
+
else
|
|
1972
|
+
Elements::Cell.new(row_index: row_index, column_index: column_index, value: value, formula: formula,
|
|
1973
|
+
style: style, raw_value: raw_value, format_code: format_code)
|
|
1974
|
+
end
|
|
1975
|
+
end
|
|
1976
|
+
end
|
|
1977
|
+
|
|
1978
|
+
# The state of a sheet when its block ended: the worksheet without its rows, the
|
|
1979
|
+
# pending rows, and the hyperlinks and comments to attach to their cells.
|
|
1980
|
+
#
|
|
1981
|
+
# @api private
|
|
1982
|
+
class Snapshot
|
|
1983
|
+
# The worksheet with every part except its rows.
|
|
1984
|
+
#: Elements::Worksheet
|
|
1985
|
+
attr_reader :frame
|
|
1986
|
+
#: Array[PendingRow]
|
|
1987
|
+
attr_reader :rows
|
|
1988
|
+
# The style log clock when each column's style was set.
|
|
1989
|
+
#: Hash[Integer, Integer]
|
|
1990
|
+
attr_reader :column_style_clocks
|
|
1991
|
+
|
|
1992
|
+
#: (Elements::Worksheet frame, Array[PendingRow] rows, Hash[String, untyped] hyperlinks, Hash[String, untyped] comments, Hash[String, Array[untyped]] threaded_comments, Hash[Integer, Integer] column_style_clocks) -> void
|
|
1993
|
+
def initialize(frame, rows, hyperlinks, comments, threaded_comments, column_style_clocks)
|
|
1994
|
+
@frame = frame
|
|
1995
|
+
@rows = rows
|
|
1996
|
+
@column_style_clocks = column_style_clocks
|
|
1997
|
+
@hyperlinks = hyperlinks
|
|
1998
|
+
@comments = comments
|
|
1999
|
+
@threaded_comments = threaded_comments
|
|
2000
|
+
@links = !(hyperlinks.empty? && comments.empty? && threaded_comments.empty?)
|
|
2001
|
+
end
|
|
2002
|
+
|
|
2003
|
+
# Returns the worksheet with +rows+, or with the rows' named cells by default.
|
|
2004
|
+
#: (?Array[Elements::Row]? rows, ?Array[Elements::Column]? columns) -> Elements::Worksheet
|
|
2005
|
+
def worksheet(rows = nil, columns = nil)
|
|
2006
|
+
rows ||= @rows.map { |row| row.to_row(attach_links(row.named_cells), row.style) }
|
|
2007
|
+
@frame.with(rows: rows, columns: columns || @frame.columns, errors: nil)
|
|
2008
|
+
end
|
|
2009
|
+
|
|
2010
|
+
# Attaches the sheet's hyperlinks and comments to the cells they refer to.
|
|
2011
|
+
#: (Array[Elements::Cell] cells) -> Array[Elements::Cell]
|
|
2012
|
+
def attach_links(cells)
|
|
2013
|
+
return cells unless @links
|
|
2014
|
+
|
|
2015
|
+
cells.map do |cell|
|
|
2016
|
+
hl = @hyperlinks[cell.ref]
|
|
2017
|
+
cm = @comments[cell.ref]
|
|
2018
|
+
tcs = @threaded_comments[cell.ref]
|
|
2019
|
+
if hl || cm || tcs
|
|
2020
|
+
cell.with(
|
|
2021
|
+
hyperlink: hl || cell.hyperlink,
|
|
2022
|
+
comment: cm || cell.comment,
|
|
2023
|
+
threaded_comments: (tcs ? (cell.threaded_comments + tcs) : cell.threaded_comments)
|
|
2024
|
+
)
|
|
2025
|
+
else
|
|
2026
|
+
cell
|
|
2027
|
+
end
|
|
2028
|
+
end
|
|
2029
|
+
end
|
|
2030
|
+
end
|
|
2031
|
+
end
|
|
2032
|
+
|
|
2033
|
+
# Stands in for the {Elements::Worksheet} of a sheet defined in {Xlsxrb.build}, as
|
|
2034
|
+
# returned by {WorkbookBuilder#sheet}. It answers the same methods with the same
|
|
2035
|
+
# results. The worksheet is built the first time one of them is called, or when the
|
|
2036
|
+
# object is frozen (as Ractor.make_shareable does), so a sheet whose return value is
|
|
2037
|
+
# never used costs nothing.
|
|
2038
|
+
#
|
|
2039
|
+
# @deprecated Read the sheet from the workbook that {Xlsxrb.build} returns. In version
|
|
2040
|
+
# 0.3.0, {WorkbookBuilder#sheet} will return the sheet's {WorksheetBuilder}, and
|
|
2041
|
+
# {WorkbookBuilder#[]} will return the {WorksheetBuilder} of an existing sheet.
|
|
2042
|
+
# @api public
|
|
2043
|
+
class DeferredWorksheet
|
|
2044
|
+
DEPRECATION_MESSAGE = "Using the sheet that WorkbookBuilder#sheet and #[] return is deprecated; " \
|
|
2045
|
+
"read it from the workbook that Xlsxrb.build returns. In version 0.3.0, sheet will return " \
|
|
2046
|
+
"the sheet's WorksheetBuilder, and #[] will return the WorksheetBuilder of an existing sheet."
|
|
2047
|
+
|
|
2048
|
+
#: (WorksheetBuilder::Snapshot snapshot) -> void
|
|
2049
|
+
def initialize(snapshot)
|
|
2050
|
+
@snapshot = snapshot
|
|
2051
|
+
@built_worksheet = nil
|
|
2052
|
+
end
|
|
2053
|
+
|
|
2054
|
+
# Returns the worksheet, building it on first use.
|
|
2055
|
+
#
|
|
2056
|
+
# @return [Elements::Worksheet]
|
|
2057
|
+
# @api public
|
|
2058
|
+
#: () -> Elements::Worksheet
|
|
2059
|
+
def worksheet = built_worksheet
|
|
2060
|
+
|
|
2061
|
+
#: (untyped other) -> bool
|
|
2062
|
+
def ==(other)
|
|
2063
|
+
built_worksheet == (other.is_a?(DeferredWorksheet) ? other.built_worksheet : other)
|
|
2064
|
+
end
|
|
2065
|
+
|
|
2066
|
+
#: (untyped other) -> bool
|
|
2067
|
+
def eql?(other)
|
|
2068
|
+
built_worksheet.eql?(other.is_a?(DeferredWorksheet) ? other.built_worksheet : other)
|
|
2069
|
+
end
|
|
2070
|
+
|
|
2071
|
+
#: () -> Integer
|
|
2072
|
+
def hash = built_worksheet.hash
|
|
2073
|
+
|
|
2074
|
+
#: () -> String
|
|
2075
|
+
def inspect = built_worksheet.inspect
|
|
2076
|
+
|
|
2077
|
+
#: () -> String
|
|
2078
|
+
def to_s = built_worksheet.to_s
|
|
2079
|
+
|
|
2080
|
+
#: (untyped printer) -> untyped
|
|
2081
|
+
def pretty_print(printer) = printer.pp(built_worksheet)
|
|
2082
|
+
|
|
2083
|
+
# Builds the worksheet before freezing, so that a frozen stand-in still answers.
|
|
2084
|
+
#: () -> self
|
|
2085
|
+
def freeze
|
|
2086
|
+
built_worksheet
|
|
2087
|
+
@snapshot = nil
|
|
2088
|
+
super
|
|
2089
|
+
end
|
|
2090
|
+
|
|
2091
|
+
# Elements::Worksheet methods, written out as the method_missing policy in
|
|
2092
|
+
# ARCHITECTURE.md requires. A test checks that they cover every public method.
|
|
2093
|
+
|
|
2094
|
+
#: (String | Symbol | Integer ref_or_row, ?Integer | String | Symbol | nil col) -> Elements::Cell?
|
|
2095
|
+
def [](ref_or_row, col = nil) = built_worksheet[ref_or_row, col]
|
|
2096
|
+
|
|
2097
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2098
|
+
def all?(...) = built_worksheet.all?(...)
|
|
2099
|
+
|
|
2100
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2101
|
+
def any?(...) = built_worksheet.any?(...)
|
|
2102
|
+
|
|
2103
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2104
|
+
def auto_filter(...) = built_worksheet.auto_filter(...)
|
|
2105
|
+
|
|
2106
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2107
|
+
def background_image(...) = built_worksheet.background_image(...)
|
|
2108
|
+
|
|
2109
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2110
|
+
def cell_watches(...) = built_worksheet.cell_watches(...)
|
|
2111
|
+
|
|
2112
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2113
|
+
def cells(...) = built_worksheet.cells(...)
|
|
2114
|
+
|
|
2115
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2116
|
+
def chain(...) = built_worksheet.chain(...)
|
|
2117
|
+
|
|
2118
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2119
|
+
def charts(...) = built_worksheet.charts(...)
|
|
2120
|
+
|
|
2121
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2122
|
+
def chunk(...) = built_worksheet.chunk(...)
|
|
2123
|
+
|
|
2124
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2125
|
+
def chunk_while(...) = built_worksheet.chunk_while(...)
|
|
2126
|
+
|
|
2127
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2128
|
+
def code_name(...) = built_worksheet.code_name(...)
|
|
2129
|
+
|
|
2130
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2131
|
+
def collect(...) = built_worksheet.collect(...)
|
|
2132
|
+
|
|
2133
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2134
|
+
def collect_concat(...) = built_worksheet.collect_concat(...)
|
|
2135
|
+
|
|
2136
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2137
|
+
def column_breaks(...) = built_worksheet.column_breaks(...)
|
|
2138
|
+
|
|
2139
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2140
|
+
def column_range(...) = built_worksheet.column_range(...)
|
|
2141
|
+
|
|
2142
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2143
|
+
def columns(...) = built_worksheet.columns(...)
|
|
2144
|
+
|
|
2145
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2146
|
+
def comment(...) = built_worksheet.comment(...)
|
|
2147
|
+
|
|
2148
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2149
|
+
def comments(...) = built_worksheet.comments(...)
|
|
2150
|
+
|
|
2151
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2152
|
+
def comments_by_ref(...) = built_worksheet.comments_by_ref(...)
|
|
2153
|
+
|
|
2154
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2155
|
+
def compact(...) = built_worksheet.compact(...)
|
|
2156
|
+
|
|
2157
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2158
|
+
def conditional_formats(...) = built_worksheet.conditional_formats(...)
|
|
2159
|
+
|
|
2160
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2161
|
+
def count(...) = built_worksheet.count(...)
|
|
2162
|
+
|
|
2163
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2164
|
+
def cycle(...) = built_worksheet.cycle(...)
|
|
2165
|
+
|
|
2166
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2167
|
+
def data_validations(...) = built_worksheet.data_validations(...)
|
|
2168
|
+
|
|
2169
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2170
|
+
def date1904?(...) = built_worksheet.date1904?(...)
|
|
2171
|
+
|
|
2172
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2173
|
+
def deconstruct(...) = built_worksheet.deconstruct(...)
|
|
2174
|
+
|
|
2175
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2176
|
+
def deconstruct_keys(...) = built_worksheet.deconstruct_keys(...)
|
|
2177
|
+
|
|
2178
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2179
|
+
def detect(...) = built_worksheet.detect(...)
|
|
2180
|
+
|
|
2181
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2182
|
+
def dimension(...) = built_worksheet.dimension(...)
|
|
2183
|
+
|
|
2184
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2185
|
+
def dimension_bounds(...) = built_worksheet.dimension_bounds(...)
|
|
2186
|
+
|
|
2187
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2188
|
+
def drop(...) = built_worksheet.drop(...)
|
|
2189
|
+
|
|
2190
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2191
|
+
def drop_while(...) = built_worksheet.drop_while(...)
|
|
2192
|
+
|
|
2193
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2194
|
+
def each(...) = built_worksheet.each(...)
|
|
2195
|
+
|
|
2196
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2197
|
+
def each_cell(...) = built_worksheet.each_cell(...)
|
|
2198
|
+
|
|
2199
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2200
|
+
def each_cons(...) = built_worksheet.each_cons(...)
|
|
2201
|
+
|
|
2202
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2203
|
+
def each_entry(...) = built_worksheet.each_entry(...)
|
|
2204
|
+
|
|
2205
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2206
|
+
def each_row(...) = built_worksheet.each_row(...)
|
|
2207
|
+
|
|
2208
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2209
|
+
def each_row_values(...) = built_worksheet.each_row_values(...)
|
|
2210
|
+
|
|
2211
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2212
|
+
def each_slice(...) = built_worksheet.each_slice(...)
|
|
2213
|
+
|
|
2214
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2215
|
+
def each_with_index(...) = built_worksheet.each_with_index(...)
|
|
2216
|
+
|
|
2217
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2218
|
+
def each_with_object(...) = built_worksheet.each_with_object(...)
|
|
2219
|
+
|
|
2220
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2221
|
+
def entries(...) = built_worksheet.entries(...)
|
|
2222
|
+
|
|
2223
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2224
|
+
def errors(...) = built_worksheet.errors(...)
|
|
2225
|
+
|
|
2226
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2227
|
+
def filter(...) = built_worksheet.filter(...)
|
|
2228
|
+
|
|
2229
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2230
|
+
def filter_columns(...) = built_worksheet.filter_columns(...)
|
|
2231
|
+
|
|
2232
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2233
|
+
def filter_map(...) = built_worksheet.filter_map(...)
|
|
2234
|
+
|
|
2235
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2236
|
+
def find(...) = built_worksheet.find(...)
|
|
2237
|
+
|
|
2238
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2239
|
+
def find_all(...) = built_worksheet.find_all(...)
|
|
2240
|
+
|
|
2241
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2242
|
+
def find_index(...) = built_worksheet.find_index(...)
|
|
2243
|
+
|
|
2244
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2245
|
+
def first(...) = built_worksheet.first(...)
|
|
2246
|
+
|
|
2247
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2248
|
+
def first_row(...) = built_worksheet.first_row(...)
|
|
2249
|
+
|
|
2250
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2251
|
+
def fit_to_page?(...) = built_worksheet.fit_to_page?(...)
|
|
2252
|
+
|
|
2253
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2254
|
+
def flat_map(...) = built_worksheet.flat_map(...)
|
|
2255
|
+
|
|
2256
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2257
|
+
def formatted_value(...) = built_worksheet.formatted_value(...)
|
|
2258
|
+
|
|
2259
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2260
|
+
def freeze_pane(...) = built_worksheet.freeze_pane(...)
|
|
2261
|
+
|
|
2262
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2263
|
+
def full_calc_on_load?(...) = built_worksheet.full_calc_on_load?(...)
|
|
2264
|
+
|
|
2265
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2266
|
+
def grep(...) = built_worksheet.grep(...)
|
|
2267
|
+
|
|
2268
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2269
|
+
def grep_v(...) = built_worksheet.grep_v(...)
|
|
2270
|
+
|
|
2271
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2272
|
+
def group_by(...) = built_worksheet.group_by(...)
|
|
2273
|
+
|
|
2274
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2275
|
+
def header_footer(...) = built_worksheet.header_footer(...)
|
|
2276
|
+
|
|
2277
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2278
|
+
def header_footer_images(...) = built_worksheet.header_footer_images(...)
|
|
2279
|
+
|
|
2280
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2281
|
+
def hidden?(...) = built_worksheet.hidden?(...)
|
|
2282
|
+
|
|
2283
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2284
|
+
def hyperlink(...) = built_worksheet.hyperlink(...)
|
|
2285
|
+
|
|
2286
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2287
|
+
def hyperlinks(...) = built_worksheet.hyperlinks(...)
|
|
2288
|
+
|
|
2289
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2290
|
+
def ignored_errors(...) = built_worksheet.ignored_errors(...)
|
|
2291
|
+
|
|
2292
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2293
|
+
def images(...) = built_worksheet.images(...)
|
|
2294
|
+
|
|
2295
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2296
|
+
def images_at(...) = built_worksheet.images_at(...)
|
|
2297
|
+
|
|
2298
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2299
|
+
def include?(...) = built_worksheet.include?(...)
|
|
2300
|
+
|
|
2301
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2302
|
+
def inject(...) = built_worksheet.inject(...)
|
|
2303
|
+
|
|
2304
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2305
|
+
def last_row(...) = built_worksheet.last_row(...)
|
|
2306
|
+
|
|
2307
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2308
|
+
def lazy(...) = built_worksheet.lazy(...)
|
|
2309
|
+
|
|
2310
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2311
|
+
def map(...) = built_worksheet.map(...)
|
|
2312
|
+
|
|
2313
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2314
|
+
def max(...) = built_worksheet.max(...)
|
|
2315
|
+
|
|
2316
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2317
|
+
def max_by(...) = built_worksheet.max_by(...)
|
|
2318
|
+
|
|
2319
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2320
|
+
def member?(...) = built_worksheet.member?(...)
|
|
2321
|
+
|
|
2322
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2323
|
+
def merged_cells(...) = built_worksheet.merged_cells(...)
|
|
2324
|
+
|
|
2325
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2326
|
+
def min(...) = built_worksheet.min(...)
|
|
2327
|
+
|
|
2328
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2329
|
+
def min_by(...) = built_worksheet.min_by(...)
|
|
2330
|
+
|
|
2331
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2332
|
+
def minmax(...) = built_worksheet.minmax(...)
|
|
2333
|
+
|
|
2334
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2335
|
+
def minmax_by(...) = built_worksheet.minmax_by(...)
|
|
2336
|
+
|
|
2337
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2338
|
+
def name(...) = built_worksheet.name(...)
|
|
2339
|
+
|
|
2340
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2341
|
+
def none?(...) = built_worksheet.none?(...)
|
|
2342
|
+
|
|
2343
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2344
|
+
def one?(...) = built_worksheet.one?(...)
|
|
2345
|
+
|
|
2346
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2347
|
+
def outline_properties(...) = built_worksheet.outline_properties(...)
|
|
2348
|
+
|
|
2349
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2350
|
+
def pad_empty_cells?(...) = built_worksheet.pad_empty_cells?(...)
|
|
2351
|
+
|
|
2352
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2353
|
+
def pad_empty_rows?(...) = built_worksheet.pad_empty_rows?(...)
|
|
2354
|
+
|
|
2355
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2356
|
+
def page_margins(...) = built_worksheet.page_margins(...)
|
|
2357
|
+
|
|
2358
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2359
|
+
def page_setup(...) = built_worksheet.page_setup(...)
|
|
2360
|
+
|
|
2361
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2362
|
+
def partition(...) = built_worksheet.partition(...)
|
|
2363
|
+
|
|
2364
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2365
|
+
def phonetic_properties(...) = built_worksheet.phonetic_properties(...)
|
|
2366
|
+
|
|
2367
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2368
|
+
def pivot_tables(...) = built_worksheet.pivot_tables(...)
|
|
2369
|
+
|
|
2370
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2371
|
+
def print_area(...) = built_worksheet.print_area(...)
|
|
2372
|
+
|
|
2373
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2374
|
+
def print_options(...) = built_worksheet.print_options(...)
|
|
2375
|
+
|
|
2376
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2377
|
+
def print_titles(...) = built_worksheet.print_titles(...)
|
|
2378
|
+
|
|
2379
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2380
|
+
def protected_ranges(...) = built_worksheet.protected_ranges(...)
|
|
2381
|
+
|
|
2382
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2383
|
+
def reduce(...) = built_worksheet.reduce(...)
|
|
2384
|
+
|
|
2385
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2386
|
+
def reject(...) = built_worksheet.reject(...)
|
|
2387
|
+
|
|
2388
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2389
|
+
def reverse_each(...) = built_worksheet.reverse_each(...)
|
|
2390
|
+
|
|
2391
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2392
|
+
def row_at(...) = built_worksheet.row_at(...)
|
|
2393
|
+
|
|
2394
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2395
|
+
def row_breaks(...) = built_worksheet.row_breaks(...)
|
|
2396
|
+
|
|
2397
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2398
|
+
def row_range(...) = built_worksheet.row_range(...)
|
|
2399
|
+
|
|
2400
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2401
|
+
def rows(...) = built_worksheet.rows(...)
|
|
2402
|
+
|
|
2403
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2404
|
+
def select(...) = built_worksheet.select(...)
|
|
2405
|
+
|
|
2406
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2407
|
+
def selection(...) = built_worksheet.selection(...)
|
|
2408
|
+
|
|
2409
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2410
|
+
def shapes(...) = built_worksheet.shapes(...)
|
|
2411
|
+
|
|
2412
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2413
|
+
def sheet_calc_properties(...) = built_worksheet.sheet_calc_properties(...)
|
|
2414
|
+
|
|
2415
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2416
|
+
def sheet_format(...) = built_worksheet.sheet_format(...)
|
|
2417
|
+
|
|
2418
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2419
|
+
def sheet_properties(...) = built_worksheet.sheet_properties(...)
|
|
2420
|
+
|
|
2421
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2422
|
+
def sheet_protection(...) = built_worksheet.sheet_protection(...)
|
|
2423
|
+
|
|
2424
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2425
|
+
def sheet_view(...) = built_worksheet.sheet_view(...)
|
|
2426
|
+
|
|
2427
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2428
|
+
def slice_after(...) = built_worksheet.slice_after(...)
|
|
2429
|
+
|
|
2430
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2431
|
+
def slice_before(...) = built_worksheet.slice_before(...)
|
|
2432
|
+
|
|
2433
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2434
|
+
def slice_when(...) = built_worksheet.slice_when(...)
|
|
2435
|
+
|
|
2436
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2437
|
+
def sort(...) = built_worksheet.sort(...)
|
|
2438
|
+
|
|
2439
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2440
|
+
def sort_by(...) = built_worksheet.sort_by(...)
|
|
2441
|
+
|
|
2442
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2443
|
+
def sort_state(...) = built_worksheet.sort_state(...)
|
|
2444
|
+
|
|
2445
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2446
|
+
def sparkline_groups(...) = built_worksheet.sparkline_groups(...)
|
|
2447
|
+
|
|
2448
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2449
|
+
def split_pane(...) = built_worksheet.split_pane(...)
|
|
2450
|
+
|
|
2451
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2452
|
+
def state(...) = built_worksheet.state(...)
|
|
2453
|
+
|
|
2454
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2455
|
+
def styles(...) = built_worksheet.styles(...)
|
|
2456
|
+
|
|
2457
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2458
|
+
def sum(...) = built_worksheet.sum(...)
|
|
2459
|
+
|
|
2460
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2461
|
+
def tab_color(...) = built_worksheet.tab_color(...)
|
|
2462
|
+
|
|
2463
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2464
|
+
def tables(...) = built_worksheet.tables(...)
|
|
2465
|
+
|
|
2466
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2467
|
+
def take(...) = built_worksheet.take(...)
|
|
2468
|
+
|
|
2469
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2470
|
+
def take_while(...) = built_worksheet.take_while(...)
|
|
2471
|
+
|
|
2472
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2473
|
+
def tally(...) = built_worksheet.tally(...)
|
|
2474
|
+
|
|
2475
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2476
|
+
def threaded_comment(...) = built_worksheet.threaded_comment(...)
|
|
2477
|
+
|
|
2478
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2479
|
+
def threaded_comments(...) = built_worksheet.threaded_comments(...)
|
|
2480
|
+
|
|
2481
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2482
|
+
def threaded_comments_at(...) = built_worksheet.threaded_comments_at(...)
|
|
2483
|
+
|
|
2484
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2485
|
+
def threaded_comments_by_ref(...) = built_worksheet.threaded_comments_by_ref(...)
|
|
2486
|
+
|
|
2487
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2488
|
+
def to_a(...) = built_worksheet.to_a(...)
|
|
2489
|
+
|
|
2490
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2491
|
+
def to_h(...) = built_worksheet.to_h(...)
|
|
2492
|
+
|
|
2493
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2494
|
+
def to_set(...) = built_worksheet.to_set(...)
|
|
2495
|
+
|
|
2496
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2497
|
+
def trim_empty_rows?(...) = built_worksheet.trim_empty_rows?(...)
|
|
2498
|
+
|
|
2499
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2500
|
+
def uniq(...) = built_worksheet.uniq(...)
|
|
2501
|
+
|
|
2502
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2503
|
+
def unmapped_data(...) = built_worksheet.unmapped_data(...)
|
|
2504
|
+
|
|
2505
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2506
|
+
def valid?(...) = built_worksheet.valid?(...)
|
|
2507
|
+
|
|
2508
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2509
|
+
def very_hidden?(...) = built_worksheet.very_hidden?(...)
|
|
2510
|
+
|
|
2511
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2512
|
+
def visible?(...) = built_worksheet.visible?(...)
|
|
2513
|
+
|
|
2514
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2515
|
+
def with(...) = built_worksheet.with(...)
|
|
2516
|
+
|
|
2517
|
+
#: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
2518
|
+
def zip(...) = built_worksheet.zip(...)
|
|
2519
|
+
|
|
2520
|
+
protected
|
|
2521
|
+
|
|
2522
|
+
# Returns the worksheet, building it on first use with a deprecation warning that
|
|
2523
|
+
# points at the caller of the public method.
|
|
2524
|
+
#: () -> Elements::Worksheet
|
|
2525
|
+
def built_worksheet
|
|
2526
|
+
@built_worksheet ||= begin
|
|
2527
|
+
Deprecation.warn(DEPRECATION_MESSAGE, uplevel: 2)
|
|
2528
|
+
@snapshot&.worksheet || raise(Error, "worksheet is not available")
|
|
2529
|
+
end
|
|
2530
|
+
end
|
|
1824
2531
|
end
|
|
1825
2532
|
|
|
1826
2533
|
# Builder context for configuring an Excel Table (ListObject) in block form.
|