xlsxrb 0.1.18 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +163 -0
- data/README.md +34 -11
- data/lib/ruby_lsp/xlsxrb/completion_listener.rb +410 -80
- data/lib/xlsxrb/chart_builder.rb +251 -386
- data/lib/xlsxrb/dsl_helpers.rb +120 -67
- data/lib/xlsxrb/elements/cell.rb +37 -157
- data/lib/xlsxrb/elements/column.rb +11 -19
- data/lib/xlsxrb/elements/coordinate_access.rb +15 -86
- data/lib/xlsxrb/elements/image.rb +5 -72
- data/lib/xlsxrb/elements/metadata.rb +463 -817
- data/lib/xlsxrb/elements/row.rb +27 -145
- data/lib/xlsxrb/elements/styles.rb +30 -88
- data/lib/xlsxrb/elements/types.rb +6 -99
- data/lib/xlsxrb/elements/workbook.rb +19 -126
- data/lib/xlsxrb/elements/worksheet.rb +43 -314
- data/lib/xlsxrb/ooxml/reader/listeners/core_listeners.rb +4 -1
- data/lib/xlsxrb/ooxml/reader/listeners/drawing_listeners.rb +7 -7
- data/lib/xlsxrb/ooxml/reader/listeners/feature_listeners.rb +32 -17
- data/lib/xlsxrb/ooxml/reader.rb +49 -51
- data/lib/xlsxrb/ooxml/styles_parser.rb +26 -2
- data/lib/xlsxrb/ooxml/utils.rb +2 -2
- data/lib/xlsxrb/ooxml/workbook_parser.rb +0 -1
- data/lib/xlsxrb/ooxml/workbook_writer.rb +172 -93
- data/lib/xlsxrb/ooxml/worksheet_parser.rb +61 -29
- data/lib/xlsxrb/ooxml/worksheet_writer.rb +65 -47
- data/lib/xlsxrb/ooxml/writer/drawing_xml.rb +28 -11
- data/lib/xlsxrb/ooxml/writer/features_xml.rb +53 -14
- data/lib/xlsxrb/ooxml/writer/styles_xml.rb +1 -1
- data/lib/xlsxrb/ooxml/writer.rb +105 -41
- data/lib/xlsxrb/ooxml/xml_parser.rb +78 -5
- data/lib/xlsxrb/ooxml/zip_reader.rb +65 -15
- data/lib/xlsxrb/ooxml/zip_writer.rb +119 -30
- data/lib/xlsxrb/stream_row.rb +12 -116
- data/lib/xlsxrb/stream_sheet.rb +14 -261
- data/lib/xlsxrb/stream_writer.rb +623 -1476
- data/lib/xlsxrb/style_builder.rb +376 -593
- data/lib/xlsxrb/version.rb +1 -1
- data/lib/xlsxrb/workbook_builder.rb +192 -226
- data/lib/xlsxrb/worksheet_builder.rb +456 -1324
- data/lib/xlsxrb.rb +266 -1083
- data/sig/generated/xlsxrb/chart_builder.rbs +202 -205
- data/sig/generated/xlsxrb/dsl_helpers.rbs +64 -16
- data/sig/generated/xlsxrb/elements/cell.rbs +12 -76
- data/sig/generated/xlsxrb/elements/column.rbs +0 -7
- data/sig/generated/xlsxrb/elements/coordinate_access.rbs +5 -41
- data/sig/generated/xlsxrb/elements/image.rbs +3 -29
- data/sig/generated/xlsxrb/elements/metadata.rbs +138 -151
- data/sig/generated/xlsxrb/elements/row.rbs +10 -53
- data/sig/generated/xlsxrb/elements/styles.rbs +1 -39
- data/sig/generated/xlsxrb/elements/workbook.rbs +14 -78
- data/sig/generated/xlsxrb/elements/worksheet.rbs +5 -121
- data/sig/generated/xlsxrb/ooxml/reader/listeners/feature_listeners.rbs +0 -4
- data/sig/generated/xlsxrb/ooxml/reader.rbs +0 -3
- data/sig/generated/xlsxrb/ooxml/styles_parser.rbs +1 -1
- data/sig/generated/xlsxrb/ooxml/utils.rbs +3 -3
- data/sig/generated/xlsxrb/ooxml/workbook_writer.rbs +12 -0
- data/sig/generated/xlsxrb/ooxml/worksheet_parser.rbs +16 -0
- data/sig/generated/xlsxrb/ooxml/worksheet_writer.rbs +5 -3
- data/sig/generated/xlsxrb/ooxml/writer/features_xml.rbs +7 -0
- data/sig/generated/xlsxrb/ooxml/writer.rbs +20 -14
- data/sig/generated/xlsxrb/ooxml/xml_parser.rbs +70 -0
- data/sig/generated/xlsxrb/ooxml/zip_reader.rbs +22 -7
- data/sig/generated/xlsxrb/ooxml/zip_writer.rbs +26 -1
- data/sig/generated/xlsxrb/stream_row.rbs +7 -42
- data/sig/generated/xlsxrb/stream_sheet.rbs +1 -158
- data/sig/generated/xlsxrb/stream_writer.rbs +457 -976
- data/sig/generated/xlsxrb/style_builder.rbs +206 -242
- data/sig/generated/xlsxrb/workbook_builder.rbs +84 -132
- data/sig/generated/xlsxrb/worksheet_builder.rbs +309 -685
- data/sig/generated/xlsxrb.rbs +43 -190
- data/sig/rexml.rbs +8 -0
- metadata +3 -5
- data/lib/xlsxrb/utils.rb +0 -251
- data/sig/generated/xlsxrb/utils.rbs +0 -200
|
@@ -9,18 +9,14 @@ module Xlsxrb
|
|
|
9
9
|
#
|
|
10
10
|
# @api public
|
|
11
11
|
class WorksheetBuilder
|
|
12
|
-
OMITTED = Object.new.freeze
|
|
13
|
-
private_constant :OMITTED
|
|
14
12
|
# @param name [String] The worksheet name.
|
|
15
13
|
# @param strict_excel_mode [Boolean] Whether to enforce Microsoft Excel limits.
|
|
16
14
|
# @param state [Symbol] Sheet visibility state (:visible, :hidden, or :very_hidden).
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def initialize(name, strict_excel_mode: true, state: :visible, escape_formulas: false)
|
|
15
|
+
#: (String name, ?strict_excel_mode: bool, ?state: Symbol) -> void
|
|
16
|
+
def initialize(name, strict_excel_mode: true, state: :visible)
|
|
20
17
|
@name = name
|
|
21
18
|
@strict_excel_mode = strict_excel_mode
|
|
22
19
|
@state = state ? state.to_sym : :visible
|
|
23
|
-
@escape_formulas = escape_formulas ? true : false
|
|
24
20
|
@next_row_index = 0
|
|
25
21
|
@rows = []
|
|
26
22
|
@columns = []
|
|
@@ -74,19 +70,6 @@ module Xlsxrb
|
|
|
74
70
|
#: Array[Hash[Symbol, untyped]]
|
|
75
71
|
attr_reader :defined_names
|
|
76
72
|
|
|
77
|
-
# @return [Boolean] Whether to treat strings starting with formula prefixes as plain text.
|
|
78
|
-
#: bool
|
|
79
|
-
attr_accessor :escape_formulas
|
|
80
|
-
|
|
81
|
-
# Returns whether formula escaping is enabled.
|
|
82
|
-
#
|
|
83
|
-
# @return [Boolean]
|
|
84
|
-
# @api public
|
|
85
|
-
#: () -> bool
|
|
86
|
-
def escape_formulas?
|
|
87
|
-
@escape_formulas ? true : false
|
|
88
|
-
end
|
|
89
|
-
|
|
90
73
|
# Defines or configures a named cell style.
|
|
91
74
|
#
|
|
92
75
|
# @example Define a bold header style
|
|
@@ -159,22 +142,11 @@ module Xlsxrb
|
|
|
159
142
|
# @param custom_height [Boolean] Whether custom row height is enforced.
|
|
160
143
|
# @param outline_level [Integer, nil] Grouping/outline hierarchy level.
|
|
161
144
|
# @param collapsed [Boolean] Whether the row is collapsed.
|
|
162
|
-
# @param styles [String, Symbol, Array<String | Symbol>, Hash, nil] Deprecated. Use cell_styles: instead.
|
|
163
|
-
# @param style [Integer, Symbol, String, Hash, nil] Deprecated. Use row_style: instead.
|
|
164
145
|
# @return [void]
|
|
165
146
|
# @raise [ArgumentError] If limits are exceeded when strict_excel_mode is enabled.
|
|
166
147
|
# @api public
|
|
167
|
-
#: (Array[untyped] | Hash[untyped, untyped] values, ?cell_styles: untyped, ?row_style: (Integer | Symbol | String | Hash[Symbol, untyped])?, ?
|
|
168
|
-
def row(values, cell_styles: nil, row_style: nil,
|
|
169
|
-
if styles
|
|
170
|
-
warn "[DEPRECATION] WorksheetBuilder#row keyword :styles is deprecated; use :cell_styles instead.", uplevel: 1
|
|
171
|
-
cell_styles ||= styles
|
|
172
|
-
end
|
|
173
|
-
if style
|
|
174
|
-
warn "[DEPRECATION] WorksheetBuilder#row keyword :style is deprecated; use :row_style instead.", uplevel: 1
|
|
175
|
-
row_style ||= style
|
|
176
|
-
end
|
|
177
|
-
|
|
148
|
+
#: (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
|
+
def row(values, cell_styles: nil, row_style: nil, height: nil, hidden: false, custom_height: false, collapsed: false, outline_level: nil)
|
|
178
150
|
row_index = @next_row_index
|
|
179
151
|
DslHelpers.validate_row_bounds!(row_index, height, strict_excel_mode: @strict_excel_mode)
|
|
180
152
|
@next_row_index += 1
|
|
@@ -192,13 +164,13 @@ module Xlsxrb
|
|
|
192
164
|
values.each_with_index do |val, idx|
|
|
193
165
|
cell_style = cell_styles.is_a?(Array) ? cell_styles[idx] : cell_styles
|
|
194
166
|
|
|
195
|
-
if val.is_a?(Date) && cell_style.nil?
|
|
196
|
-
|
|
167
|
+
if val.is_a?(Date) && !val.is_a?(DateTime) && cell_style.nil?
|
|
168
|
+
style("__xlsxrb_date", number_format: "yyyy-mm-dd") unless @styles.key?("__xlsxrb_date")
|
|
197
169
|
cell_styles = [] if cell_styles.nil?
|
|
198
170
|
cell_styles = Array.new(values.size, cell_styles) unless cell_styles.is_a?(Array)
|
|
199
171
|
cell_styles[idx] = "__xlsxrb_date"
|
|
200
|
-
elsif val.is_a?(Time) && cell_style.nil?
|
|
201
|
-
|
|
172
|
+
elsif (val.is_a?(Time) || val.is_a?(DateTime)) && cell_style.nil?
|
|
173
|
+
style("__xlsxrb_time", number_format: "yyyy-mm-dd hh:mm:ss") unless @styles.key?("__xlsxrb_time")
|
|
202
174
|
cell_styles = [] if cell_styles.nil?
|
|
203
175
|
cell_styles = Array.new(values.size, cell_styles) unless cell_styles.is_a?(Array)
|
|
204
176
|
cell_styles[idx] = "__xlsxrb_time"
|
|
@@ -238,7 +210,7 @@ module Xlsxrb
|
|
|
238
210
|
|
|
239
211
|
if style_name.is_a?(Hash)
|
|
240
212
|
inline_name = "__inline_#{style_name.hash}"
|
|
241
|
-
|
|
213
|
+
style(inline_name, **style_name) unless @styles.key?(inline_name)
|
|
242
214
|
style_name = inline_name
|
|
243
215
|
end
|
|
244
216
|
if val.nil? && style_name.nil?
|
|
@@ -260,16 +232,16 @@ module Xlsxrb
|
|
|
260
232
|
raw_value: val.cached_value&.to_s,
|
|
261
233
|
format_code: fmt_code
|
|
262
234
|
)
|
|
263
|
-
elsif val.is_a?(Hash) && (val.key?(:formula) || val.key?(:expression) || (val[:type]&.to_sym == :shared &&
|
|
235
|
+
elsif val.is_a?(Hash) && (val.key?(:formula) || val.key?(:expression) || (val[:type]&.to_sym == :shared && val.key?(:shared_index)))
|
|
264
236
|
cached_val = val.key?(:value) ? val[:value] : val[:cached_value]
|
|
265
237
|
f_expr = val[:formula] || val[:expression] || ""
|
|
266
|
-
f_type = val[:type] || (:shared if val.key?(:shared_index)
|
|
238
|
+
f_type = val[:type] || (:shared if val.key?(:shared_index))
|
|
267
239
|
f_obj = Elements::Formula.new(
|
|
268
240
|
expression: f_expr,
|
|
269
241
|
cached_value: cached_val,
|
|
270
242
|
type: f_type,
|
|
271
243
|
ref: val[:ref],
|
|
272
|
-
shared_index: val[:shared_index]
|
|
244
|
+
shared_index: val[:shared_index],
|
|
273
245
|
calculate_always: val[:calculate_always]
|
|
274
246
|
)
|
|
275
247
|
Elements::Cell.new(
|
|
@@ -295,7 +267,7 @@ module Xlsxrb
|
|
|
295
267
|
end
|
|
296
268
|
|
|
297
269
|
cells.compact!
|
|
298
|
-
unmapped =
|
|
270
|
+
unmapped = Elements::EMPTY_HASH
|
|
299
271
|
@rows << Elements::Row.new(
|
|
300
272
|
index: row_index,
|
|
301
273
|
cells: cells,
|
|
@@ -308,8 +280,6 @@ module Xlsxrb
|
|
|
308
280
|
unmapped_data: unmapped
|
|
309
281
|
)
|
|
310
282
|
end
|
|
311
|
-
# @deprecated Use {#row} instead. Will be removed in 0.2.0 (available via xlsxrb-adapters).
|
|
312
|
-
alias add_row row
|
|
313
283
|
|
|
314
284
|
# Appends a row to the worksheet and returns self for chaining.
|
|
315
285
|
#
|
|
@@ -327,9 +297,6 @@ module Xlsxrb
|
|
|
327
297
|
|
|
328
298
|
# Advances the row cursor by count without writing empty row elements.
|
|
329
299
|
#
|
|
330
|
-
# @example Skip one row
|
|
331
|
-
# sheet.skip_row
|
|
332
|
-
#
|
|
333
300
|
# @example Skip multiple rows
|
|
334
301
|
# sheet.skip_rows(3)
|
|
335
302
|
#
|
|
@@ -342,8 +309,6 @@ module Xlsxrb
|
|
|
342
309
|
|
|
343
310
|
@next_row_index += count
|
|
344
311
|
end
|
|
345
|
-
# @deprecated Use {#skip_rows} instead. Will be removed in 0.2.0.
|
|
346
|
-
alias skip_row skip_rows
|
|
347
312
|
|
|
348
313
|
# Sets column formatting and properties for one or multiple columns.
|
|
349
314
|
#
|
|
@@ -369,8 +334,8 @@ module Xlsxrb
|
|
|
369
334
|
if existing_idx
|
|
370
335
|
prev = @columns[existing_idx]
|
|
371
336
|
new_width = width.nil? ? prev.width : width
|
|
372
|
-
new_custom_width = (custom_width || !width.nil?) || prev.custom_width
|
|
373
|
-
new_hidden = hidden || prev.hidden
|
|
337
|
+
new_custom_width = (custom_width || !width.nil?) || prev.custom_width?
|
|
338
|
+
new_hidden = hidden || prev.hidden?
|
|
374
339
|
new_outline = outline_level.nil? ? prev.outline_level : outline_level
|
|
375
340
|
new_style = style.nil? ? prev.style_index : style
|
|
376
341
|
unmapped = prev.unmapped_data ? prev.unmapped_data.dup : {}
|
|
@@ -434,12 +399,6 @@ module Xlsxrb
|
|
|
434
399
|
def group_columns(index, level: 1, collapsed: false, hidden: false, width: nil, style: nil)
|
|
435
400
|
column(index, outline_level: level, collapsed: collapsed, hidden: hidden, width: width, style: style)
|
|
436
401
|
end
|
|
437
|
-
# @deprecated Use {#group_columns} instead. Will be removed in 0.2.0.
|
|
438
|
-
alias group_column group_columns
|
|
439
|
-
# @deprecated Use {#group_columns} instead. Will be removed in 0.2.0.
|
|
440
|
-
alias group_cols group_columns
|
|
441
|
-
# @deprecated Use {#group_columns} instead. Will be removed in 0.2.0.
|
|
442
|
-
alias group_col group_columns
|
|
443
402
|
|
|
444
403
|
# Groups multiple rows with outline hierarchy, either by range or with a block.
|
|
445
404
|
#
|
|
@@ -489,9 +448,9 @@ module Xlsxrb
|
|
|
489
448
|
index: existing_row.index,
|
|
490
449
|
cells: existing_row.cells,
|
|
491
450
|
height: existing_row.height,
|
|
492
|
-
hidden: hidden || existing_row.hidden
|
|
493
|
-
custom_height: existing_row.custom_height
|
|
494
|
-
collapsed: collapsed || existing_row.collapsed
|
|
451
|
+
hidden: hidden || existing_row.hidden?,
|
|
452
|
+
custom_height: existing_row.custom_height?,
|
|
453
|
+
collapsed: collapsed || existing_row.collapsed?,
|
|
495
454
|
outline_level: level,
|
|
496
455
|
style_index: existing_row.style_index,
|
|
497
456
|
unmapped_data: existing_row.unmapped_data
|
|
@@ -502,10 +461,11 @@ module Xlsxrb
|
|
|
502
461
|
end
|
|
503
462
|
end
|
|
504
463
|
end
|
|
505
|
-
# @deprecated Use {#group_rows} instead. Will be removed in 0.2.0.
|
|
506
|
-
alias group_row group_rows
|
|
507
464
|
|
|
508
|
-
# Configures worksheet-level outline and grouping view properties.
|
|
465
|
+
# Configures or queries worksheet-level outline and grouping view properties.
|
|
466
|
+
#
|
|
467
|
+
# When called with no arguments, returns the outline properties Hash.
|
|
468
|
+
# When called with arguments, updates outline properties and returns nil.
|
|
509
469
|
#
|
|
510
470
|
# @example Show summary row below detail rows
|
|
511
471
|
# sheet.outline_properties(summary_below: true, summary_right: true)
|
|
@@ -513,21 +473,19 @@ module Xlsxrb
|
|
|
513
473
|
# @param summary_below [Boolean, nil] Flag indicating if summary rows appear below detail rows.
|
|
514
474
|
# @param summary_right [Boolean, nil] Flag indicating if summary columns appear to the right of detail columns.
|
|
515
475
|
# @param show_outline_symbols [Boolean, nil] Flag indicating whether outline symbols are visible.
|
|
516
|
-
# @param show_symbols [Boolean, nil] Deprecated alias for show_outline_symbols.
|
|
517
476
|
# @param apply_styles [Boolean, nil] Flag indicating whether automatic styles apply to outlines.
|
|
518
477
|
# @param opts [Hash] Additional options.
|
|
519
478
|
# @return [Hash<Symbol, untyped>, void]
|
|
520
479
|
# @api public
|
|
521
|
-
#: (
|
|
522
|
-
|
|
523
|
-
|
|
480
|
+
#: () -> Hash[Symbol, untyped]
|
|
481
|
+
#: (?summary_below: bool?, ?summary_right: bool?, ?show_outline_symbols: bool?, ?apply_styles: bool?, **untyped opts) -> void
|
|
482
|
+
def outline_properties(summary_below: nil, summary_right: nil, show_outline_symbols: nil, apply_styles: nil, **opts)
|
|
483
|
+
return @sheet_properties.slice(:summary_below, :summary_right, :show_outline_symbols, :apply_styles) if summary_below.nil? && summary_right.nil? && show_outline_symbols.nil? && apply_styles.nil? && opts.empty?
|
|
524
484
|
|
|
525
|
-
warn "[Xlsxrb DEPRECATION] outline_properties keyword show_symbols: is deprecated; use show_outline_symbols: instead.", uplevel: 1 unless show_symbols.nil?
|
|
526
485
|
props = (@sheet_properties[:outline_properties] || {}).dup
|
|
527
486
|
props[:summary_below] = summary_below unless summary_below.nil?
|
|
528
487
|
props[:summary_right] = summary_right unless summary_right.nil?
|
|
529
|
-
|
|
530
|
-
props[:show_outline_symbols] = symbols unless symbols.nil?
|
|
488
|
+
props[:show_outline_symbols] = show_outline_symbols unless show_outline_symbols.nil?
|
|
531
489
|
props[:apply_styles] = apply_styles unless apply_styles.nil?
|
|
532
490
|
props.merge!(opts)
|
|
533
491
|
@sheet_properties[:outline_properties] = props
|
|
@@ -535,8 +493,6 @@ module Xlsxrb
|
|
|
535
493
|
@sheet_properties[:summary_right] = props[:summary_right] unless props[:summary_right].nil?
|
|
536
494
|
nil
|
|
537
495
|
end
|
|
538
|
-
# @deprecated Use {#outline_properties} instead. Will be removed in 0.2.0.
|
|
539
|
-
alias outline_pr outline_properties
|
|
540
496
|
|
|
541
497
|
# Sets worksheet outline and grouping view properties.
|
|
542
498
|
#
|
|
@@ -549,7 +505,6 @@ module Xlsxrb
|
|
|
549
505
|
outline_properties(**h)
|
|
550
506
|
nil
|
|
551
507
|
end
|
|
552
|
-
alias outline_pr= outline_properties=
|
|
553
508
|
|
|
554
509
|
# Adds a chart to the worksheet.
|
|
555
510
|
#
|
|
@@ -564,7 +519,7 @@ module Xlsxrb
|
|
|
564
519
|
options = options.merge(type: type) if type
|
|
565
520
|
if block_given?
|
|
566
521
|
builder = ChartBuilder.new
|
|
567
|
-
builder.type
|
|
522
|
+
builder.type = type if type
|
|
568
523
|
yield builder
|
|
569
524
|
options = builder.options.merge(options)
|
|
570
525
|
end
|
|
@@ -600,16 +555,12 @@ module Xlsxrb
|
|
|
600
555
|
@hyperlinks << link
|
|
601
556
|
end
|
|
602
557
|
|
|
603
|
-
#
|
|
558
|
+
# Returns the auto-filter range for the worksheet, or nil if none.
|
|
604
559
|
#
|
|
605
|
-
# @
|
|
606
|
-
# @return [void]
|
|
560
|
+
# @return [String, nil]
|
|
607
561
|
# @api public
|
|
608
|
-
#: (
|
|
609
|
-
|
|
610
|
-
@auto_filter = range
|
|
611
|
-
nil
|
|
612
|
-
end
|
|
562
|
+
#: () -> String?
|
|
563
|
+
attr_reader :auto_filter
|
|
613
564
|
|
|
614
565
|
# Sets the auto-filter range for the worksheet.
|
|
615
566
|
#
|
|
@@ -618,8 +569,7 @@ module Xlsxrb
|
|
|
618
569
|
# @api public
|
|
619
570
|
#: (String? range) -> String?
|
|
620
571
|
def auto_filter=(range)
|
|
621
|
-
auto_filter
|
|
622
|
-
range
|
|
572
|
+
@auto_filter = range&.to_s
|
|
623
573
|
end
|
|
624
574
|
|
|
625
575
|
# Configures filtering rules on a specific column of an auto-filter.
|
|
@@ -628,30 +578,35 @@ module Xlsxrb
|
|
|
628
578
|
# @param filter [Hash] Filter criteria (e.g. values, custom filters).
|
|
629
579
|
# @return [void]
|
|
630
580
|
# @api public
|
|
631
|
-
#: (Integer | String | Symbol col_id, untyped filter) -> void
|
|
581
|
+
#: (Integer | String | Symbol col_id, (Hash[untyped, untyped] | Array[untyped]) filter) -> void
|
|
632
582
|
def filter_column(col_id, filter)
|
|
633
583
|
col_id = Elements::Cell._column_index(col_id) if col_id.is_a?(String) || col_id.is_a?(Symbol)
|
|
634
584
|
@filter_columns[col_id] = filter
|
|
635
585
|
nil
|
|
636
586
|
end
|
|
637
587
|
|
|
638
|
-
# Configures column sort state for the sheet.
|
|
588
|
+
# Configures or queries column sort state for the sheet.
|
|
589
|
+
#
|
|
590
|
+
# When called with no arguments, returns the {Elements::SortState} value object.
|
|
591
|
+
# When called with arguments, updates sort state and returns nil.
|
|
639
592
|
#
|
|
640
|
-
# @param ref [String] The sorted range.
|
|
641
|
-
# @param sort_conditions [Array<Hash
|
|
593
|
+
# @param ref [String, nil] The sorted range.
|
|
594
|
+
# @param sort_conditions [Array<Hash>, nil] List of sort condition definitions.
|
|
595
|
+
# @param case_sensitive [Boolean] Whether sorting is case sensitive.
|
|
596
|
+
# @param sort_method [String, nil] Sort method.
|
|
642
597
|
# @param opts [Hash] Additional sort state options.
|
|
643
|
-
# @return [Elements::SortState,
|
|
598
|
+
# @return [Elements::SortState, nil, void]
|
|
644
599
|
# @api public
|
|
645
|
-
#: (
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
return Elements::SortState.new(**@sort_state)
|
|
650
|
-
|
|
651
|
-
return @sort_state
|
|
600
|
+
#: () -> Elements::SortState?
|
|
601
|
+
#: (?String? ref, ?Array[Hash[untyped, untyped]]? sort_conditions, ?case_sensitive: bool, ?sort_method: String?, **untyped opts) -> void
|
|
602
|
+
def sort_state(ref = nil, sort_conditions = nil, case_sensitive: false, sort_method: nil, **opts)
|
|
603
|
+
if ref.nil? && sort_conditions.nil?
|
|
604
|
+
return @sort_state ? Elements::SortState.new(**@sort_state) : nil
|
|
652
605
|
end
|
|
653
606
|
|
|
654
|
-
|
|
607
|
+
entry = { ref: ref, sort_conditions: sort_conditions, case_sensitive: case_sensitive }
|
|
608
|
+
entry[:sort_method] = sort_method if sort_method
|
|
609
|
+
@sort_state = entry.merge(opts)
|
|
655
610
|
nil
|
|
656
611
|
end
|
|
657
612
|
|
|
@@ -660,7 +615,7 @@ module Xlsxrb
|
|
|
660
615
|
# @param opts [Elements::SortState, Hash, nil] Sort state options.
|
|
661
616
|
# @return [void]
|
|
662
617
|
# @api public
|
|
663
|
-
#: (untyped opts) -> void
|
|
618
|
+
#: (Elements::SortState | Hash[Symbol, untyped] | nil opts) -> void
|
|
664
619
|
def sort_state=(opts)
|
|
665
620
|
@sort_state = opts&.respond_to?(:to_h) ? opts.to_h : opts
|
|
666
621
|
nil
|
|
@@ -679,13 +634,6 @@ module Xlsxrb
|
|
|
679
634
|
@data_validations.concat(normalized_list)
|
|
680
635
|
end
|
|
681
636
|
|
|
682
|
-
# @deprecated Use {#data_validation} instead.
|
|
683
|
-
#: (?String? sqref, **untyped opts) ?{ (DataValidationBuilder) -> void } -> void
|
|
684
|
-
def validate_data(...)
|
|
685
|
-
warn "[DEPRECATION] `validate_data` is deprecated; use `data_validation` instead.", uplevel: 1
|
|
686
|
-
data_validation(...)
|
|
687
|
-
end
|
|
688
|
-
|
|
689
637
|
# Adds a conditional formatting rule to a cell range.
|
|
690
638
|
# Supports block configuration via {ConditionalFormatBuilder} and coordinate targeting (:columns, :rows).
|
|
691
639
|
#
|
|
@@ -737,29 +685,22 @@ module Xlsxrb
|
|
|
737
685
|
# @param source_ref [String] Source data range (e.g. "DataSheet!A1:D100").
|
|
738
686
|
# @param row_fields [Array<Integer, String>] Field names or indices for row headers.
|
|
739
687
|
# @param data_fields [Array<Hash>] Data aggregation fields.
|
|
740
|
-
# @param
|
|
741
|
-
# @param
|
|
688
|
+
# @param column_fields [Array<String, Integer>, nil] Field names or indices for columns.
|
|
689
|
+
# @param ref [String, nil] Target cell for pivot table top-left corner (e.g. "E1").
|
|
742
690
|
# @param name [String, nil] Pivot table name.
|
|
743
691
|
# @param field_names [Array<String>, nil] Custom field display names.
|
|
744
|
-
# @param items [Array, nil]
|
|
745
|
-
# @param column_fields [Array<String, Integer>] Field names or indices for columns.
|
|
746
|
-
# @param col_fields [Array<String, Integer>] Deprecated alias for column_fields.
|
|
747
|
-
# @param ref [String] Target cell for pivot table top-left corner (e.g. "E1").
|
|
748
|
-
# @param dest_ref [String] Deprecated alias for ref.
|
|
692
|
+
# @param items [Hash{Integer => Array}, nil] Items of each field, by 0-based field index.
|
|
749
693
|
# @return [void]
|
|
750
694
|
# @api public
|
|
751
|
-
#: (String source_ref, row_fields: Array[String | Integer], data_fields: Array[String | Hash[Symbol, untyped]], ?column_fields: Array[String | Integer]?, ?
|
|
752
|
-
def pivot_table(source_ref, row_fields:, data_fields:, column_fields: nil,
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
c_fields = column_fields || col_fields || []
|
|
756
|
-
target_ref = ref || dest_ref || "E1"
|
|
695
|
+
#: (String source_ref, row_fields: Array[String | Integer], data_fields: Array[String | Hash[Symbol, untyped]], ?column_fields: Array[String | Integer]?, ?ref: String?, ?name: String?, ?field_names: Array[String]?, ?items: Hash[Integer, Array[untyped]]?, **untyped opts) -> void
|
|
696
|
+
def pivot_table(source_ref, row_fields:, data_fields:, column_fields: nil, ref: nil, name: nil, field_names: nil, items: nil, **opts)
|
|
697
|
+
c_fields = column_fields || []
|
|
698
|
+
target_ref = ref || "E1"
|
|
757
699
|
@pivot_tables ||= []
|
|
758
700
|
entry = {
|
|
759
701
|
source_ref: source_ref, row_fields: row_fields,
|
|
760
702
|
data_fields: data_fields, column_fields: c_fields,
|
|
761
|
-
|
|
762
|
-
dest_ref: target_ref, name: name,
|
|
703
|
+
ref: target_ref, destination: target_ref, name: name,
|
|
763
704
|
field_names: field_names, items: items
|
|
764
705
|
}.merge(opts)
|
|
765
706
|
@pivot_tables << entry
|
|
@@ -770,12 +711,13 @@ module Xlsxrb
|
|
|
770
711
|
# @param cell [String, Integer] Cell reference (e.g. "B2").
|
|
771
712
|
# @param text [String] The comment text.
|
|
772
713
|
# @param author [String] Author name.
|
|
714
|
+
# @param visible [Boolean] Whether the comment is always shown instead of on hover.
|
|
773
715
|
# @return [void]
|
|
774
716
|
# @api public
|
|
775
|
-
#: (String | Integer cell, String text, ?author: ::String) -> void
|
|
776
|
-
def comment(cell, text, author: "Author")
|
|
717
|
+
#: (String | Integer cell, String text, ?author: ::String, ?visible: bool) -> void
|
|
718
|
+
def comment(cell, text, author: "Author", visible: false)
|
|
777
719
|
ref_str = cell.to_s
|
|
778
|
-
@comments << { ref: ref_str, text: text, author: author }
|
|
720
|
+
@comments << { ref: ref_str, text: text, author: author, visible: visible }
|
|
779
721
|
nil
|
|
780
722
|
end
|
|
781
723
|
|
|
@@ -800,17 +742,18 @@ module Xlsxrb
|
|
|
800
742
|
text: text,
|
|
801
743
|
author: author,
|
|
802
744
|
timestamp: timestamp,
|
|
745
|
+
created_at: timestamp,
|
|
803
746
|
id: id,
|
|
804
747
|
parent_id: parent_id,
|
|
805
748
|
done: done ? true : false,
|
|
749
|
+
resolved: done ? true : false,
|
|
806
750
|
user_id: user_id,
|
|
751
|
+
author_id: user_id,
|
|
807
752
|
provider_id: provider_id
|
|
808
753
|
}.compact
|
|
809
754
|
@threaded_comments << entry
|
|
810
755
|
nil
|
|
811
756
|
end
|
|
812
|
-
# @deprecated Use {#threaded_comment} instead. Will be removed in 0.2.0.
|
|
813
|
-
alias add_threaded_comment threaded_comment
|
|
814
757
|
|
|
815
758
|
# Adds a sparkline group to the sheet.
|
|
816
759
|
#
|
|
@@ -827,84 +770,43 @@ module Xlsxrb
|
|
|
827
770
|
@sparkline_groups << group
|
|
828
771
|
end
|
|
829
772
|
|
|
830
|
-
# Adds a single sparkline to the sheet.
|
|
831
|
-
#
|
|
832
|
-
# @example Add a line sparkline
|
|
833
|
-
# sheet.add_sparkline(location: "F1", range: "A1:E1")
|
|
834
|
-
#
|
|
835
|
-
# @example Add a column sparkline with high/low markers
|
|
836
|
-
# sheet.add_sparkline(location: "F2", range: "A2:E2", type: :column, high: true, low: true)
|
|
837
|
-
#
|
|
838
|
-
# @example Add a win/loss sparkline
|
|
839
|
-
# sheet.add_sparkline(location: "F3", range: "A3:E3", type: :win_loss)
|
|
840
|
-
#
|
|
841
|
-
# @deprecated Use {#sparkline_group} instead. Will be removed in 0.2.0.
|
|
842
|
-
# @param location [String, nil] Target cell for the sparkline (e.g. "F1").
|
|
843
|
-
# @param range [String, nil] Data range for the sparkline (e.g. "A1:E1").
|
|
844
|
-
# @param type [Symbol, String, nil] Sparkline type (:line, :column, :win_loss / :stacked).
|
|
845
|
-
# @param opts [Hash] Additional sparkline options.
|
|
846
|
-
# @return [void]
|
|
847
|
-
# @api public
|
|
848
|
-
#: (?location: String?, ?range: String?, ?type: (String | Symbol)?, **untyped opts) -> void
|
|
849
|
-
def add_sparkline(location: nil, range: nil, type: nil, **opts)
|
|
850
|
-
warn "[DEPRECATION] #add_sparkline is deprecated; use #sparkline_group instead.", uplevel: 1
|
|
851
|
-
loc = location || opts.delete(:location_ref)
|
|
852
|
-
rng = range || opts.delete(:data_ref) || opts.delete(:data)
|
|
853
|
-
raise ArgumentError, "Missing required location: parameter for sparkline" unless loc
|
|
854
|
-
raise ArgumentError, "Missing required range: parameter for sparkline" unless rng
|
|
855
|
-
|
|
856
|
-
mapped_type = case type&.to_s
|
|
857
|
-
when "win_loss" then "stacked"
|
|
858
|
-
when nil, "" then nil
|
|
859
|
-
else type.to_s
|
|
860
|
-
end
|
|
861
|
-
sparkline_group(sparklines: [{ data_ref: rng.to_s, location_ref: loc.to_s }], type: mapped_type, **opts)
|
|
862
|
-
end
|
|
863
|
-
|
|
864
773
|
# Merges a range of cells into a single cell.
|
|
865
774
|
#
|
|
866
775
|
# @example Merge with string range
|
|
867
776
|
# sheet.merge("A1:C1")
|
|
868
777
|
#
|
|
869
|
-
# @
|
|
870
|
-
# @param range [String, Hash, nil] Cell range (e.g. "A1:B2") or hash of coordinates.
|
|
871
|
-
# @param row [Integer, nil] Single row index.
|
|
872
|
-
# @param col_start [Integer, String, nil] Starting column.
|
|
873
|
-
# @param col_end [Integer, String, nil] Ending column.
|
|
874
|
-
# @param row_start [Integer, nil] Starting row index.
|
|
875
|
-
# @param row_end [Integer, nil] Ending row index.
|
|
778
|
+
# @param range [String] Cell range (e.g. "A1:B2").
|
|
876
779
|
# @return [void]
|
|
877
780
|
# @api public
|
|
878
|
-
#: (
|
|
879
|
-
def merge(range
|
|
880
|
-
canonical = DslHelpers.normalize_merge_range(
|
|
881
|
-
range,
|
|
882
|
-
row: row, col_start: col_start, col_end: col_end,
|
|
883
|
-
row_start: row_start, row_end: row_end,
|
|
884
|
-
strict_excel_mode: @strict_excel_mode
|
|
885
|
-
)
|
|
781
|
+
#: (String range) -> void
|
|
782
|
+
def merge(range)
|
|
783
|
+
canonical = DslHelpers.normalize_merge_range(range, strict_excel_mode: @strict_excel_mode)
|
|
886
784
|
@merge_cells_ranges << canonical unless @merge_cells_ranges.include?(canonical)
|
|
887
785
|
end
|
|
888
786
|
|
|
889
|
-
#
|
|
787
|
+
# Configures or queries freeze panes (<pane state="frozen">).
|
|
788
|
+
#
|
|
789
|
+
# When called with no arguments, returns the {Elements::FreezePane} value object or nil.
|
|
790
|
+
# When called with arguments, configures the freeze pane and returns nil.
|
|
890
791
|
#
|
|
891
792
|
# @param row [Integer, nil] Number of rows to freeze from top (0-based split position).
|
|
892
793
|
# @param column [Integer, String, nil] Number of columns to freeze from left (0-based or letter).
|
|
893
|
-
# @param
|
|
894
|
-
# @
|
|
794
|
+
# @param top_left_cell [String, nil] Top-left cell reference in bottom-right pane.
|
|
795
|
+
# @param active_pane [String, Symbol, nil] Active pane identifier.
|
|
796
|
+
# @return [Elements::FreezePane, nil, void]
|
|
895
797
|
# @api public
|
|
896
|
-
#: (
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
return Elements::FreezePane.new(**@freeze_pane)
|
|
901
|
-
|
|
902
|
-
return @freeze_pane
|
|
798
|
+
#: () -> Elements::FreezePane?
|
|
799
|
+
#: (?row: Integer | nil, ?column: (Integer | String)?, ?top_left_cell: String?, ?active_pane: (String | Symbol)?) -> void
|
|
800
|
+
def freeze_pane(row: nil, column: nil, top_left_cell: nil, active_pane: nil)
|
|
801
|
+
if row.nil? && column.nil? && top_left_cell.nil? && active_pane.nil?
|
|
802
|
+
return @freeze_pane ? Elements::FreezePane.new(**@freeze_pane) : nil
|
|
903
803
|
end
|
|
904
804
|
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
805
|
+
c = column ? Elements::Cell._column_index(column) : 0
|
|
806
|
+
entry = { row: row || 0, column: c }
|
|
807
|
+
entry[:top_left_cell] = top_left_cell if top_left_cell
|
|
808
|
+
entry[:active_pane] = active_pane.to_s if active_pane
|
|
809
|
+
@freeze_pane = entry
|
|
908
810
|
nil
|
|
909
811
|
end
|
|
910
812
|
|
|
@@ -913,7 +815,7 @@ module Xlsxrb
|
|
|
913
815
|
# @param opts [Elements::FreezePane, Hash, nil] Freeze pane options.
|
|
914
816
|
# @return [void]
|
|
915
817
|
# @api public
|
|
916
|
-
#: (untyped opts) -> void
|
|
818
|
+
#: (Elements::FreezePane | Hash[Symbol, untyped] | nil opts) -> void
|
|
917
819
|
def freeze_pane=(opts)
|
|
918
820
|
if opts.nil?
|
|
919
821
|
@freeze_pane = nil
|
|
@@ -921,32 +823,34 @@ module Xlsxrb
|
|
|
921
823
|
h = opts.respond_to?(:to_h) ? opts.to_h : opts
|
|
922
824
|
c = h[:column] || h[:col]
|
|
923
825
|
c = Elements::Cell._column_index(c) if c
|
|
924
|
-
|
|
826
|
+
entry = { row: h[:row] || 0, column: c || 0 }
|
|
827
|
+
entry[:top_left_cell] = h[:top_left_cell] if h[:top_left_cell]
|
|
828
|
+
entry[:active_pane] = h[:active_pane].to_s if h[:active_pane]
|
|
829
|
+
@freeze_pane = entry
|
|
925
830
|
end
|
|
926
831
|
nil
|
|
927
832
|
end
|
|
928
833
|
|
|
929
|
-
# Splits window panes without freezing or queries split pane settings.
|
|
834
|
+
# Splits window panes without freezing or queries split pane settings (<pane>).
|
|
835
|
+
#
|
|
836
|
+
# When called with no arguments, returns the {Elements::SplitPane} value object or nil.
|
|
837
|
+
# When called with arguments, configures the split pane and returns nil.
|
|
930
838
|
#
|
|
931
839
|
# @param x_split [Integer, nil] Horizontal split offset in points.
|
|
932
840
|
# @param y_split [Integer, nil] Vertical split offset in points.
|
|
933
841
|
# @param top_left_cell [String, nil] Top-left cell reference in bottom-right pane.
|
|
934
842
|
# @param active_pane [String, Symbol, nil] Active pane identifier.
|
|
935
|
-
# @
|
|
936
|
-
# @return [Elements::SplitPane, Hash<Symbol, untyped>, nil, void]
|
|
843
|
+
# @return [Elements::SplitPane, nil, void]
|
|
937
844
|
# @api public
|
|
938
|
-
#: (
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
return Elements::SplitPane.new(**@split_pane)
|
|
943
|
-
|
|
944
|
-
return @split_pane
|
|
845
|
+
#: () -> Elements::SplitPane?
|
|
846
|
+
#: (?x_split: Integer | nil, ?y_split: Integer | nil, ?top_left_cell: String?, ?active_pane: (String | Symbol)?) -> void
|
|
847
|
+
def split_pane(x_split: nil, y_split: nil, top_left_cell: nil, active_pane: nil)
|
|
848
|
+
if x_split.nil? && y_split.nil? && top_left_cell.nil? && active_pane.nil?
|
|
849
|
+
return @split_pane ? Elements::SplitPane.new(**@split_pane) : nil
|
|
945
850
|
end
|
|
946
851
|
|
|
947
852
|
entry = { x_split: x_split || 0, y_split: y_split || 0, top_left_cell: top_left_cell }
|
|
948
853
|
entry[:active_pane] = active_pane.to_s if active_pane
|
|
949
|
-
entry[:state] = state.to_s if state
|
|
950
854
|
@split_pane = entry
|
|
951
855
|
nil
|
|
952
856
|
end
|
|
@@ -956,7 +860,7 @@ module Xlsxrb
|
|
|
956
860
|
# @param opts [Elements::SplitPane, Hash, nil] Split pane options.
|
|
957
861
|
# @return [void]
|
|
958
862
|
# @api public
|
|
959
|
-
#: (untyped opts) -> void
|
|
863
|
+
#: (Elements::SplitPane | Hash[Symbol, untyped] | nil opts) -> void
|
|
960
864
|
def split_pane=(opts)
|
|
961
865
|
if opts.nil?
|
|
962
866
|
@split_pane = nil
|
|
@@ -964,31 +868,29 @@ module Xlsxrb
|
|
|
964
868
|
h = opts.respond_to?(:to_h) ? opts.to_h : opts
|
|
965
869
|
entry = { x_split: h[:x_split] || 0, y_split: h[:y_split] || 0, top_left_cell: h[:top_left_cell] }
|
|
966
870
|
entry[:active_pane] = h[:active_pane].to_s if h[:active_pane]
|
|
967
|
-
entry[:state] = h[:state].to_s if h[:state]
|
|
968
871
|
@split_pane = entry
|
|
969
872
|
end
|
|
970
873
|
nil
|
|
971
874
|
end
|
|
972
875
|
|
|
973
|
-
#
|
|
876
|
+
# Configures or queries the active cell and selection area (<selection>).
|
|
877
|
+
#
|
|
878
|
+
# When called with no arguments, returns the selection ({Elements::Selection}, Array, or nil).
|
|
879
|
+
# When called with arguments, updates the selection and returns nil.
|
|
974
880
|
#
|
|
975
881
|
# @param active_cell [String, nil] Active cell reference (e.g. "A1") or range (e.g. "A1:D10").
|
|
976
882
|
# @param sqref [String, nil] Selected range reference (e.g. "A1:D10").
|
|
977
883
|
# @param pane [String, Symbol, nil] Target pane (:topLeft, :topRight, :bottomLeft, :bottomRight).
|
|
978
|
-
# @return [Elements::Selection, Array<Elements::Selection>,
|
|
884
|
+
# @return [Elements::Selection, Array<Elements::Selection>, nil, void]
|
|
979
885
|
# @api public
|
|
980
|
-
#: (
|
|
886
|
+
#: () -> (Elements::Selection | Array[Elements::Selection])?
|
|
887
|
+
#: (?String? active_cell, ?sqref: String?, ?pane: (String | Symbol)?) -> void
|
|
981
888
|
def selection(active_cell = nil, sqref: nil, pane: nil)
|
|
982
889
|
if active_cell.nil? && sqref.nil? && pane.nil?
|
|
983
890
|
return nil if @selection.nil?
|
|
891
|
+
return @selection.map { |s| Elements::Selection.new(**s) } if @selection.is_a?(Array)
|
|
984
892
|
|
|
985
|
-
|
|
986
|
-
return @selection.map { |s| Elements::Selection.new(**s) } if @selection.is_a?(Array)
|
|
987
|
-
|
|
988
|
-
return Elements::Selection.new(**@selection)
|
|
989
|
-
end
|
|
990
|
-
|
|
991
|
-
return @selection
|
|
893
|
+
return Elements::Selection.new(**@selection)
|
|
992
894
|
end
|
|
993
895
|
|
|
994
896
|
if sqref.nil? && active_cell.is_a?(String) && active_cell.include?(":")
|
|
@@ -997,8 +899,9 @@ module Xlsxrb
|
|
|
997
899
|
else
|
|
998
900
|
sqref ||= active_cell
|
|
999
901
|
end
|
|
1000
|
-
|
|
1001
|
-
|
|
902
|
+
sel = { active_cell: active_cell, sqref: sqref }
|
|
903
|
+
sel[:pane] = pane if pane
|
|
904
|
+
@selection = sel
|
|
1002
905
|
nil
|
|
1003
906
|
end
|
|
1004
907
|
|
|
@@ -1007,7 +910,7 @@ module Xlsxrb
|
|
|
1007
910
|
# @param opts [Elements::Selection, Array<Elements::Selection, Hash>, Hash, nil]
|
|
1008
911
|
# @return [void]
|
|
1009
912
|
# @api public
|
|
1010
|
-
#: (untyped opts) -> void
|
|
913
|
+
#: (Elements::Selection | Array[Elements::Selection | Hash[Symbol, untyped]] | Hash[Symbol, untyped] | nil opts) -> void
|
|
1011
914
|
def selection=(opts)
|
|
1012
915
|
@selection = if opts.nil?
|
|
1013
916
|
nil
|
|
@@ -1019,16 +922,9 @@ module Xlsxrb
|
|
|
1019
922
|
nil
|
|
1020
923
|
end
|
|
1021
924
|
|
|
1022
|
-
# @deprecated Use {#selection} instead.
|
|
1023
|
-
#: (String active_cell, ?sqref: String?, ?pane: (String | Symbol)?) -> void
|
|
1024
|
-
def select_cell(...)
|
|
1025
|
-
warn "[DEPRECATION] `select_cell` is deprecated; use `selection` instead.", uplevel: 1
|
|
1026
|
-
selection(...)
|
|
1027
|
-
end
|
|
1028
|
-
|
|
1029
925
|
# Configures or queries page margins in inches for printing (<pageMargins>).
|
|
1030
926
|
#
|
|
1031
|
-
# When called with no arguments, returns the
|
|
927
|
+
# When called with no arguments, returns the {Elements::PageMargins} value object or nil.
|
|
1032
928
|
# When called with arguments, configures page margins and returns nil.
|
|
1033
929
|
#
|
|
1034
930
|
# @param left [Float, nil] Left margin.
|
|
@@ -1037,15 +933,13 @@ module Xlsxrb
|
|
|
1037
933
|
# @param bottom [Float, nil] Bottom margin.
|
|
1038
934
|
# @param header [Float, nil] Header margin.
|
|
1039
935
|
# @param footer [Float, nil] Footer margin.
|
|
1040
|
-
# @return [Elements::PageMargins,
|
|
936
|
+
# @return [Elements::PageMargins, nil, void]
|
|
1041
937
|
# @api public
|
|
1042
|
-
#: (
|
|
938
|
+
#: () -> Elements::PageMargins?
|
|
939
|
+
#: (?left: Float?, ?right: Float?, ?top: Float?, ?bottom: Float?, ?header: Float?, ?footer: Float?) -> void
|
|
1043
940
|
def page_margins(left: nil, right: nil, top: nil, bottom: nil, header: nil, footer: nil)
|
|
1044
941
|
if left.nil? && right.nil? && top.nil? && bottom.nil? && header.nil? && footer.nil?
|
|
1045
|
-
return
|
|
1046
|
-
return Elements::PageMargins.new(**@page_margins) if defined?(Elements::PageMargins)
|
|
1047
|
-
|
|
1048
|
-
return @page_margins
|
|
942
|
+
return @page_margins ? Elements::PageMargins.new(**@page_margins) : nil
|
|
1049
943
|
end
|
|
1050
944
|
|
|
1051
945
|
@page_margins = DslHelpers.normalize_page_margins(
|
|
@@ -1059,7 +953,7 @@ module Xlsxrb
|
|
|
1059
953
|
# @param opts [Hash, Elements::PageMargins, nil]
|
|
1060
954
|
# @return [void]
|
|
1061
955
|
# @api public
|
|
1062
|
-
#: (untyped opts) -> void
|
|
956
|
+
#: (Hash[Symbol, untyped] | Elements::PageMargins | nil opts) -> void
|
|
1063
957
|
def page_margins=(opts)
|
|
1064
958
|
if opts.nil?
|
|
1065
959
|
@page_margins = nil
|
|
@@ -1072,17 +966,16 @@ module Xlsxrb
|
|
|
1072
966
|
|
|
1073
967
|
# Configures or queries page setup configuration (<pageSetup>).
|
|
1074
968
|
#
|
|
1075
|
-
# When called with no arguments, returns the
|
|
969
|
+
# When called with no arguments, returns the {Elements::PageSetup} value object.
|
|
1076
970
|
# When called with keyword arguments, updates page setup and returns nil.
|
|
1077
971
|
#
|
|
1078
972
|
# @param opts [Hash] Page setup options (e.g. orientation: :landscape, paper_size: 9).
|
|
1079
|
-
# @return [Elements::PageSetup,
|
|
973
|
+
# @return [Elements::PageSetup, void]
|
|
1080
974
|
# @api public
|
|
1081
|
-
#: (
|
|
975
|
+
#: () -> Elements::PageSetup
|
|
976
|
+
#: (**untyped opts) -> void
|
|
1082
977
|
def page_setup(**opts)
|
|
1083
|
-
if opts.empty?
|
|
1084
|
-
return defined?(Elements::PageSetup) ? Elements::PageSetup.new(**@page_setup) : @page_setup
|
|
1085
|
-
end
|
|
978
|
+
return Elements::PageSetup.new(**@page_setup) if opts.empty?
|
|
1086
979
|
|
|
1087
980
|
@page_setup.merge!(opts)
|
|
1088
981
|
@sheet_properties[:fit_to_page] = true if (opts.key?(:fit_to_width) || opts.key?(:fit_to_height)) && !@sheet_properties.key?(:fit_to_page)
|
|
@@ -1094,44 +987,20 @@ module Xlsxrb
|
|
|
1094
987
|
# @param opts [Hash, Elements::PageSetup]
|
|
1095
988
|
# @return [void]
|
|
1096
989
|
# @api public
|
|
1097
|
-
#: (untyped opts) -> void
|
|
990
|
+
#: (Hash[Symbol, untyped] | Elements::PageSetup opts) -> void
|
|
1098
991
|
def page_setup=(opts)
|
|
1099
992
|
h = opts.respond_to?(:to_h) ? opts.to_h : (opts || {})
|
|
1100
993
|
@page_setup = h.transform_keys(&:to_sym)
|
|
1101
994
|
nil
|
|
1102
995
|
end
|
|
1103
996
|
|
|
1104
|
-
#
|
|
1105
|
-
# When enabled, optionally sets fit_to_width and/or fit_to_height on page_setup.
|
|
997
|
+
# Returns whether page setup fits content to page width/height.
|
|
1106
998
|
#
|
|
1107
|
-
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#fit_to_page=} or {#page_setup} with :fit_to_width/:fit_to_height instead.
|
|
1108
|
-
# @param enabled [Boolean, nil] Whether to fit to page.
|
|
1109
|
-
# @param width [Integer, nil] Pages wide to fit to.
|
|
1110
|
-
# @param height [Integer, nil] Pages tall to fit to.
|
|
1111
|
-
# @return [Boolean, void]
|
|
1112
|
-
# @api public
|
|
1113
|
-
#: (?bool? enabled, ?width: Integer?, ?height: Integer?) -> (bool | void)
|
|
1114
|
-
def fit_to_page(enabled = OMITTED, width: nil, height: nil)
|
|
1115
|
-
if enabled.equal?(OMITTED) && width.nil? && height.nil?
|
|
1116
|
-
return @sheet_properties[:fit_to_page] ? true : false
|
|
1117
|
-
end
|
|
1118
|
-
|
|
1119
|
-
@sheet_properties[:fit_to_page] = if enabled.equal?(OMITTED)
|
|
1120
|
-
true
|
|
1121
|
-
else
|
|
1122
|
-
enabled ? true : false
|
|
1123
|
-
end
|
|
1124
|
-
page_setup(fit_to_width: width) if width
|
|
1125
|
-
page_setup(fit_to_height: height) if height
|
|
1126
|
-
end
|
|
1127
|
-
|
|
1128
|
-
# @deprecated Use {#fit_to_page} instead. Will be removed in 0.2.0.
|
|
1129
999
|
# @return [Boolean]
|
|
1130
1000
|
# @api public
|
|
1131
1001
|
#: () -> bool
|
|
1132
1002
|
def fit_to_page?
|
|
1133
|
-
|
|
1134
|
-
fit_to_page
|
|
1003
|
+
@sheet_properties[:fit_to_page] ? true : false
|
|
1135
1004
|
end
|
|
1136
1005
|
|
|
1137
1006
|
# Sets whether page setup fits content to page width/height.
|
|
@@ -1146,17 +1015,16 @@ module Xlsxrb
|
|
|
1146
1015
|
|
|
1147
1016
|
# Configures or queries headers and footers for printing (<headerFooter>).
|
|
1148
1017
|
#
|
|
1149
|
-
# When called with no arguments, returns the
|
|
1018
|
+
# When called with no arguments, returns the {Elements::HeaderFooter} value object.
|
|
1150
1019
|
# When called with keyword arguments, updates headers and footers and returns nil.
|
|
1151
1020
|
#
|
|
1152
1021
|
# @param opts [Hash] Header and footer options (e.g. odd_header: "&CHeader Text").
|
|
1153
|
-
# @return [Elements::HeaderFooter,
|
|
1022
|
+
# @return [Elements::HeaderFooter, void]
|
|
1154
1023
|
# @api public
|
|
1155
|
-
#: (
|
|
1024
|
+
#: () -> Elements::HeaderFooter
|
|
1025
|
+
#: (**untyped opts) -> void
|
|
1156
1026
|
def header_footer(**opts)
|
|
1157
|
-
if opts.empty?
|
|
1158
|
-
return defined?(Elements::HeaderFooter) ? Elements::HeaderFooter.new(**@header_footer) : @header_footer
|
|
1159
|
-
end
|
|
1027
|
+
return Elements::HeaderFooter.new(**@header_footer) if opts.empty?
|
|
1160
1028
|
|
|
1161
1029
|
@header_footer.merge!(opts)
|
|
1162
1030
|
nil
|
|
@@ -1167,7 +1035,7 @@ module Xlsxrb
|
|
|
1167
1035
|
# @param opts [Hash, Elements::HeaderFooter]
|
|
1168
1036
|
# @return [void]
|
|
1169
1037
|
# @api public
|
|
1170
|
-
#: (untyped opts) -> void
|
|
1038
|
+
#: (Hash[Symbol, untyped] | Elements::HeaderFooter opts) -> void
|
|
1171
1039
|
def header_footer=(opts)
|
|
1172
1040
|
h = opts.respond_to?(:to_h) ? opts.to_h : (opts || {})
|
|
1173
1041
|
@header_footer = h.transform_keys(&:to_sym)
|
|
@@ -1177,22 +1045,16 @@ module Xlsxrb
|
|
|
1177
1045
|
# Configures or queries print options (<printOptions>).
|
|
1178
1046
|
#
|
|
1179
1047
|
# When called with no arguments, returns the {Elements::PrintOptions} value object.
|
|
1180
|
-
# When called with
|
|
1048
|
+
# When called with keyword options, configures print options and returns nil.
|
|
1181
1049
|
#
|
|
1182
|
-
# @param name [Symbol, String, Hash, Elements::MetadataRecord, nil] Option name or hash/record of options.
|
|
1183
|
-
# @param value [Object, nil] Option value.
|
|
1184
1050
|
# @param opts [Hash] Additional print options.
|
|
1185
1051
|
# @return [Elements::PrintOptions, void]
|
|
1186
1052
|
# @api public
|
|
1187
|
-
#: (
|
|
1188
|
-
|
|
1189
|
-
|
|
1053
|
+
#: () -> Elements::PrintOptions
|
|
1054
|
+
#: (**untyped opts) -> void
|
|
1055
|
+
def print_options(**opts)
|
|
1056
|
+
return Elements::PrintOptions.new(**@print_options) if opts.empty?
|
|
1190
1057
|
|
|
1191
|
-
if name.is_a?(Hash) || (name.respond_to?(:to_h) && !name.is_a?(Symbol) && !name.is_a?(String))
|
|
1192
|
-
opts = name.to_h.merge(opts)
|
|
1193
|
-
name = nil
|
|
1194
|
-
end
|
|
1195
|
-
@print_options[name.to_sym] = value if name && !value.nil?
|
|
1196
1058
|
opts.each { |k, v| @print_options[k.to_sym] = v }
|
|
1197
1059
|
nil
|
|
1198
1060
|
end
|
|
@@ -1215,57 +1077,34 @@ module Xlsxrb
|
|
|
1215
1077
|
# @param name [String] Defined name identifier.
|
|
1216
1078
|
# @param value [Object, nil] Cell reference, formula, or constant.
|
|
1217
1079
|
# @param hidden [Boolean] Whether the defined name is hidden from Excel's UI.
|
|
1218
|
-
# @param column [Integer, String, nil] Deprecated alias for columns.
|
|
1219
1080
|
# @param columns [Integer, String, nil] Column index or letter for coordinate-based reference.
|
|
1220
|
-
# @param
|
|
1221
|
-
# @param row [Integer, Range, nil] Deprecated alias for rows.
|
|
1222
|
-
# @param rows [Integer, Range, nil] Row or row range (1-based) for coordinate-based reference.
|
|
1081
|
+
# @param rows [Integer, Range, nil] Row or row range (0-based) for coordinate-based reference.
|
|
1223
1082
|
# @param range [String, nil] Cell range reference (e.g. "A1:A10").
|
|
1224
1083
|
# @param sheet [String, nil] Reference sheet name (defaults to current sheet).
|
|
1225
1084
|
# @param scope [String, Symbol, nil] Scope identifier (:workbook or sheet name).
|
|
1226
|
-
# @param local [Boolean] Deprecated alias for scope: :current.
|
|
1227
1085
|
# @return [void]
|
|
1228
1086
|
# @api public
|
|
1229
|
-
#: (String name, ?untyped value, ?hidden: bool, ?
|
|
1230
|
-
def defined_name(name, value = nil, hidden: false,
|
|
1231
|
-
warn "[DEPRECATION] `col:` is deprecated; use `column:` (or `columns:`) instead.", uplevel: 1 if col
|
|
1232
|
-
warn "[DEPRECATION] `local:` is deprecated; use `scope:` instead.", uplevel: 1 if local
|
|
1233
|
-
warn "[Xlsxrb DEPRECATION] defined_name keyword column: is deprecated; use columns: instead.", uplevel: 1 unless column.nil?
|
|
1234
|
-
warn "[Xlsxrb DEPRECATION] defined_name keyword row: is deprecated; use rows: instead.", uplevel: 1 unless row.nil?
|
|
1235
|
-
c_arg = column || columns || col
|
|
1236
|
-
r_arg = row || rows
|
|
1087
|
+
#: (String name, ?untyped value, ?hidden: bool, ?columns: untyped, ?rows: untyped, ?range: untyped, ?sheet: String?, ?scope: (String | Symbol)?) -> void
|
|
1088
|
+
def defined_name(name, value = nil, hidden: false, columns: nil, rows: nil, range: nil, sheet: nil, scope: nil)
|
|
1237
1089
|
ref_sheet = sheet || @name
|
|
1238
|
-
normalized_val = DslHelpers.normalize_defined_name_value(value, sheet: ref_sheet,
|
|
1090
|
+
normalized_val = DslHelpers.normalize_defined_name_value(value, sheet: ref_sheet, columns: columns, rows: rows, range: range)
|
|
1239
1091
|
entry = { name: name, value: normalized_val, hidden: hidden }
|
|
1240
1092
|
local_sheet = if scope
|
|
1241
1093
|
scope == :workbook ? nil : scope.to_s
|
|
1242
|
-
elsif local
|
|
1243
|
-
@name || sheet
|
|
1244
|
-
else
|
|
1245
|
-
sheet
|
|
1246
1094
|
end
|
|
1247
1095
|
entry[:local_sheet_name] = local_sheet if local_sheet
|
|
1248
1096
|
@defined_names << entry
|
|
1249
1097
|
end
|
|
1250
1098
|
|
|
1251
|
-
#
|
|
1252
|
-
#
|
|
1253
|
-
# @example Set print area range
|
|
1254
|
-
# sheet.print_area("A1:H50")
|
|
1099
|
+
# Returns the print area for the worksheet, or nil if none.
|
|
1255
1100
|
#
|
|
1256
1101
|
# @example Get print area range
|
|
1257
1102
|
# sheet.print_area #=> "A1:H50"
|
|
1258
1103
|
#
|
|
1259
|
-
# @
|
|
1260
|
-
# @return [String, nil, void]
|
|
1104
|
+
# @return [String, nil]
|
|
1261
1105
|
# @api public
|
|
1262
|
-
#: (
|
|
1263
|
-
|
|
1264
|
-
return @print_area if range.nil?
|
|
1265
|
-
|
|
1266
|
-
@print_area = range&.to_s
|
|
1267
|
-
nil
|
|
1268
|
-
end
|
|
1106
|
+
#: () -> String?
|
|
1107
|
+
attr_reader :print_area
|
|
1269
1108
|
|
|
1270
1109
|
# Sets the print area for the worksheet.
|
|
1271
1110
|
#
|
|
@@ -1279,31 +1118,27 @@ module Xlsxrb
|
|
|
1279
1118
|
|
|
1280
1119
|
# Sets or gets repeating print titles (rows and/or columns) for pagination.
|
|
1281
1120
|
#
|
|
1121
|
+
# When called with no arguments, returns the {Elements::PrintTitles} value object or nil.
|
|
1122
|
+
# When called with arguments, updates print titles and returns nil.
|
|
1123
|
+
#
|
|
1282
1124
|
# @example Set repeating header rows
|
|
1283
1125
|
# sheet.print_titles(rows: "1:2")
|
|
1284
1126
|
#
|
|
1285
1127
|
# @example Get repeating print titles
|
|
1286
|
-
# sheet.print_titles #=>
|
|
1128
|
+
# sheet.print_titles #=> #<Xlsxrb::Elements::PrintTitles ...>
|
|
1287
1129
|
#
|
|
1288
|
-
# @param rows [String, nil] Repeating row range (e.g. "1:2").
|
|
1289
1130
|
# @param rows [String, Integer, Range, nil] Repeating row range (e.g. "1:2" or 0-based 0..1).
|
|
1290
1131
|
# @param columns [String, Integer, Symbol, Range, nil] Repeating column range (e.g. "A:B" or 0..1).
|
|
1291
|
-
# @param cols [String, Integer, Symbol, Range, nil] Deprecated alias for columns.
|
|
1292
1132
|
# @return [Elements::PrintTitles, nil, void]
|
|
1293
1133
|
# @api public
|
|
1294
|
-
#: (
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
return Elements::PrintTitles.new(**@print_titles)
|
|
1300
|
-
end
|
|
1134
|
+
#: () -> Elements::PrintTitles?
|
|
1135
|
+
#: (?rows: (String | Integer | Range[Integer])?, ?columns: (String | Integer | Symbol | Range[untyped])?) -> void
|
|
1136
|
+
def print_titles(rows: nil, columns: nil)
|
|
1137
|
+
return @print_titles ? Elements::PrintTitles.new(**@print_titles) : nil if rows.nil? && columns.nil?
|
|
1301
1138
|
|
|
1302
|
-
warn "[DEPRECATION] `cols:` is deprecated; use `columns:` instead.", uplevel: 1 if cols && columns.nil?
|
|
1303
|
-
c = columns || cols
|
|
1304
1139
|
norm_rows = DslHelpers.normalize_print_titles_rows(rows)
|
|
1305
|
-
norm_cols = DslHelpers.normalize_print_titles_columns(
|
|
1306
|
-
@print_titles = Elements::PrintTitles.new(rows: norm_rows, columns: norm_cols
|
|
1140
|
+
norm_cols = DslHelpers.normalize_print_titles_columns(columns)
|
|
1141
|
+
@print_titles = Elements::PrintTitles.new(rows: norm_rows, columns: norm_cols)
|
|
1307
1142
|
nil
|
|
1308
1143
|
end
|
|
1309
1144
|
|
|
@@ -1380,21 +1215,19 @@ module Xlsxrb
|
|
|
1380
1215
|
print_titles(rows: existing_rows, columns: cols_str)
|
|
1381
1216
|
end
|
|
1382
1217
|
|
|
1383
|
-
#
|
|
1218
|
+
# Sets or queries sheet-level protection with optional password hashing (<sheetProtection>).
|
|
1384
1219
|
#
|
|
1385
|
-
# When called with no arguments, returns the
|
|
1220
|
+
# When called with no arguments, returns the {Elements::SheetProtection} value object or nil.
|
|
1386
1221
|
# When called with keyword arguments, sets sheet protection and returns nil.
|
|
1387
1222
|
#
|
|
1388
1223
|
# @param opts [Hash] Protection options (e.g. password: "secret", select_locked_cells: true).
|
|
1389
|
-
# @return [Elements::SheetProtection,
|
|
1224
|
+
# @return [Elements::SheetProtection, nil, void]
|
|
1390
1225
|
# @api public
|
|
1391
|
-
#: (
|
|
1226
|
+
#: () -> Elements::SheetProtection?
|
|
1227
|
+
#: (**untyped opts) -> void
|
|
1392
1228
|
def sheet_protection(**opts)
|
|
1393
1229
|
if opts.empty?
|
|
1394
|
-
|
|
1395
|
-
return Elements::SheetProtection.new(**@sheet_protection) if defined?(Elements::SheetProtection)
|
|
1396
|
-
|
|
1397
|
-
@sheet_protection
|
|
1230
|
+
@sheet_protection ? Elements::SheetProtection.new(**@sheet_protection) : nil
|
|
1398
1231
|
else
|
|
1399
1232
|
@sheet_protection = DslHelpers.normalize_protection_options(opts)
|
|
1400
1233
|
nil
|
|
@@ -1406,7 +1239,7 @@ module Xlsxrb
|
|
|
1406
1239
|
# @param opts [Elements::SheetProtection, Hash, Boolean, nil]
|
|
1407
1240
|
# @return [void]
|
|
1408
1241
|
# @api public
|
|
1409
|
-
#: (untyped opts) -> void
|
|
1242
|
+
#: (Elements::SheetProtection | Hash[Symbol, untyped] | bool | nil opts) -> void
|
|
1410
1243
|
def sheet_protection=(opts)
|
|
1411
1244
|
if opts.nil? || opts == false
|
|
1412
1245
|
@sheet_protection = nil
|
|
@@ -1419,60 +1252,50 @@ module Xlsxrb
|
|
|
1419
1252
|
nil
|
|
1420
1253
|
end
|
|
1421
1254
|
|
|
1422
|
-
# @deprecated Use {#sheet_protection} instead.
|
|
1423
|
-
#: (**untyped opts) -> void
|
|
1424
|
-
def protect_sheet(...)
|
|
1425
|
-
warn "[DEPRECATION] `protect_sheet` is deprecated; use `sheet_protection` instead.", uplevel: 1
|
|
1426
|
-
sheet_protection(...)
|
|
1427
|
-
end
|
|
1428
|
-
|
|
1429
1255
|
# Inserts an embedded image from raw binary data.
|
|
1430
1256
|
#
|
|
1431
1257
|
# @param file_data [String] Binary image data.
|
|
1432
1258
|
# @param ext [String] File extension ("png", "jpeg", etc.).
|
|
1433
1259
|
# @param from_column [Integer, nil] Top-left starting column (0-based).
|
|
1434
|
-
# @param from_col [Integer, nil] Deprecated alias for from_column.
|
|
1435
1260
|
# @param from_row [Integer] Top-left starting row (0-based).
|
|
1436
1261
|
# @param to_column [Integer, nil] Bottom-right ending column (0-based).
|
|
1437
|
-
# @param to_col [Integer, nil] Deprecated alias for to_column.
|
|
1438
1262
|
# @param to_row [Integer] Bottom-right ending row (0-based).
|
|
1439
1263
|
# @param opts [Hash] Additional image anchoring options.
|
|
1440
1264
|
# @return [void]
|
|
1441
1265
|
# @api public
|
|
1442
|
-
#: (String file_data, ?ext: ::String, ?from_column: ::Integer?, ?
|
|
1443
|
-
def image(file_data, ext: "png", from_column: nil,
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
tc = to_column || to_col || 5
|
|
1448
|
-
img = { file_data: file_data, ext: ext, from_column: fc, from_col: fc, from_row: from_row, to_column: tc, to_col: tc, to_row: to_row }
|
|
1266
|
+
#: (String file_data, ?ext: ::String, ?from_column: ::Integer?, ?from_row: ::Integer, ?to_column: ::Integer?, ?to_row: ::Integer, **untyped opts) -> void
|
|
1267
|
+
def image(file_data, ext: "png", from_column: nil, from_row: 0, to_column: nil, to_row: 10, **opts)
|
|
1268
|
+
fc = from_column || 0
|
|
1269
|
+
tc = to_column || 5
|
|
1270
|
+
img = { file_data: file_data, ext: ext, from_column: fc, from_row: from_row, to_column: tc, to_row: to_row }
|
|
1449
1271
|
img.merge!(opts)
|
|
1450
1272
|
@images << img
|
|
1451
1273
|
end
|
|
1452
1274
|
|
|
1453
|
-
#
|
|
1454
|
-
#
|
|
1455
|
-
# @example Set background image from binary data
|
|
1456
|
-
# sheet.background_image(png_bytes, ext: "png")
|
|
1275
|
+
# Gets the worksheet background image (<picture>).
|
|
1457
1276
|
#
|
|
1458
|
-
# @
|
|
1459
|
-
# sheet.background_image("path/to/background.png")
|
|
1460
|
-
#
|
|
1461
|
-
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#background_image=} instead.
|
|
1462
|
-
# @param file_data [String, Hash, Elements::Image, nil] Image binary data, file path, or image options hash.
|
|
1463
|
-
# @param ext [String, nil] Image extension ("png", "jpeg", "jpg", "gif", etc.).
|
|
1464
|
-
# @param opts [Hash] Additional image options.
|
|
1465
|
-
# @return [Hash, nil]
|
|
1277
|
+
# @return [Elements::BackgroundImage, nil]
|
|
1466
1278
|
# @api public
|
|
1467
|
-
#: (
|
|
1468
|
-
def background_image
|
|
1469
|
-
|
|
1470
|
-
|
|
1279
|
+
#: () -> Elements::BackgroundImage?
|
|
1280
|
+
def background_image
|
|
1281
|
+
return nil unless @background_image
|
|
1282
|
+
|
|
1283
|
+
@background_image.is_a?(Elements::BackgroundImage) ? @background_image : Elements::BackgroundImage.new(**@background_image)
|
|
1284
|
+
end
|
|
1471
1285
|
|
|
1472
|
-
|
|
1286
|
+
# Sets the worksheet background image (<picture>).
|
|
1287
|
+
#
|
|
1288
|
+
# @param val [String, Hash, Elements::Image, nil] Image binary data, file path, or image options hash.
|
|
1289
|
+
# @return [untyped]
|
|
1290
|
+
# @api public
|
|
1291
|
+
#: (untyped val) -> untyped
|
|
1292
|
+
def background_image=(val)
|
|
1293
|
+
if val.nil?
|
|
1294
|
+
@background_image = nil
|
|
1295
|
+
return
|
|
1473
1296
|
end
|
|
1474
1297
|
|
|
1475
|
-
data =
|
|
1298
|
+
data = val
|
|
1476
1299
|
inferred_ext = nil
|
|
1477
1300
|
if data.is_a?(String) && !data.include?("\x00") && File.file?(data)
|
|
1478
1301
|
inferred_ext = File.extname(data).delete_prefix(".").downcase
|
|
@@ -1485,7 +1308,7 @@ module Xlsxrb
|
|
|
1485
1308
|
data = data.data
|
|
1486
1309
|
end
|
|
1487
1310
|
|
|
1488
|
-
final_ext = (
|
|
1311
|
+
final_ext = (inferred_ext || (val.is_a?(Hash) ? val[:ext] : nil) || "png").to_s.delete_prefix(".").downcase
|
|
1489
1312
|
mime = case final_ext
|
|
1490
1313
|
when "png" then "image/png"
|
|
1491
1314
|
when "jpg", "jpeg" then "image/jpeg"
|
|
@@ -1496,75 +1319,46 @@ module Xlsxrb
|
|
|
1496
1319
|
else "application/octet-stream"
|
|
1497
1320
|
end
|
|
1498
1321
|
|
|
1322
|
+
opts = val.is_a?(Hash) ? val : {}
|
|
1499
1323
|
@background_image = {
|
|
1500
1324
|
data: data&.b,
|
|
1501
1325
|
file_data: data&.b,
|
|
1326
|
+
extension: final_ext,
|
|
1502
1327
|
ext: final_ext,
|
|
1328
|
+
path: "background.#{final_ext}",
|
|
1503
1329
|
filename: "background.#{final_ext}",
|
|
1504
1330
|
content_type: mime
|
|
1505
1331
|
}.merge(opts).freeze
|
|
1506
|
-
end
|
|
1507
|
-
# @deprecated Use {#background_image} instead. Will be removed in 0.2.0.
|
|
1508
|
-
alias background_picture background_image
|
|
1509
|
-
# @deprecated Use {#background_image} instead. Will be removed in 0.2.0.
|
|
1510
|
-
alias picture background_image
|
|
1511
|
-
|
|
1512
|
-
#: (untyped val) -> untyped
|
|
1513
|
-
def background_image=(val)
|
|
1514
|
-
if val.nil?
|
|
1515
|
-
@background_image = nil
|
|
1516
|
-
else
|
|
1517
|
-
background_image(val)
|
|
1518
|
-
end
|
|
1519
1332
|
val
|
|
1520
1333
|
end
|
|
1521
|
-
# @deprecated Use {#background_image=} instead. Will be removed in 0.2.0.
|
|
1522
|
-
alias background_picture= background_image=
|
|
1523
|
-
# @deprecated Use {#background_image=} instead. Will be removed in 0.2.0.
|
|
1524
|
-
alias picture= background_image=
|
|
1525
1334
|
|
|
1526
1335
|
# Inserts a drawing shape (e.g. rectangle, callout, arrow).
|
|
1527
1336
|
#
|
|
1528
1337
|
# @param preset [String] Shape preset name (e.g. "rect", "roundRect").
|
|
1529
1338
|
# @param text [String, nil] Shape label text.
|
|
1530
1339
|
# @param from_column [Integer, nil] Top-left column.
|
|
1531
|
-
# @param from_col [Integer, nil] Deprecated alias for from_column.
|
|
1532
1340
|
# @param from_row [Integer] Top-left row.
|
|
1533
1341
|
# @param to_column [Integer, nil] Bottom-right column.
|
|
1534
|
-
# @param to_col [Integer, nil] Deprecated alias for to_column.
|
|
1535
1342
|
# @param to_row [Integer] Bottom-right row.
|
|
1536
1343
|
# @param opts [Hash] Additional shape formatting options.
|
|
1537
1344
|
# @return [void]
|
|
1538
1345
|
# @api public
|
|
1539
|
-
#: (**untyped opts) -> void
|
|
1540
|
-
def shape(preset: "rect", text: nil, from_column: nil,
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
tc = to_column || to_col || 5
|
|
1545
|
-
shape_data = { preset: preset, text: text, from_column: fc, from_col: fc, from_row: from_row, to_column: tc, to_col: tc, to_row: to_row }
|
|
1346
|
+
#: (?preset: String, ?text: String?, ?from_column: Integer?, ?from_row: Integer, ?to_column: Integer?, ?to_row: Integer, **untyped opts) -> void
|
|
1347
|
+
def shape(preset: "rect", text: nil, from_column: nil, from_row: 0, to_column: nil, to_row: 5, **opts)
|
|
1348
|
+
fc = from_column || 0
|
|
1349
|
+
tc = to_column || 5
|
|
1350
|
+
shape_data = { preset: preset, text: text, from_column: fc, from_row: from_row, to_column: tc, to_row: to_row }
|
|
1546
1351
|
shape_data[:name] = opts.delete(:name) || "Shape #{@shapes.size + 1}"
|
|
1547
1352
|
shape_data.merge!(opts)
|
|
1548
1353
|
@shapes << shape_data
|
|
1549
1354
|
end
|
|
1550
1355
|
|
|
1551
|
-
# Gets
|
|
1356
|
+
# Gets the sheet visibility state (:visible, :hidden, or :very_hidden).
|
|
1552
1357
|
#
|
|
1553
|
-
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#state=} instead.
|
|
1554
|
-
# @param new_state [Symbol, nil] The new state.
|
|
1555
1358
|
# @return [Symbol]
|
|
1556
1359
|
# @api public
|
|
1557
|
-
#:
|
|
1558
|
-
|
|
1559
|
-
if new_state
|
|
1560
|
-
val = new_state.to_sym
|
|
1561
|
-
raise ArgumentError, "Invalid sheet state ':#{val}'. Allowed states are :visible, :hidden, :very_hidden" unless VALID_SHEET_STATES.include?(val)
|
|
1562
|
-
|
|
1563
|
-
@state = val
|
|
1564
|
-
else
|
|
1565
|
-
@state
|
|
1566
|
-
end
|
|
1567
|
-
end
|
|
1360
|
+
#: Symbol
|
|
1361
|
+
attr_reader :state
|
|
1568
1362
|
|
|
1569
1363
|
# Sets the sheet visibility state (:visible, :hidden, or :very_hidden).
|
|
1570
1364
|
#
|
|
@@ -1579,30 +1373,13 @@ module Xlsxrb
|
|
|
1579
1373
|
@state = val
|
|
1580
1374
|
end
|
|
1581
1375
|
|
|
1582
|
-
# Gets
|
|
1376
|
+
# Gets the worksheet tab color.
|
|
1583
1377
|
#
|
|
1584
|
-
# @
|
|
1585
|
-
# @overload tab_color()
|
|
1586
|
-
# Returns the current tab color specification.
|
|
1587
|
-
# @return [String, Hash, nil]
|
|
1588
|
-
# @overload tab_color(spec, **opts)
|
|
1589
|
-
# Sets the tab color using an RGB hex string or color options.
|
|
1590
|
-
# @param spec [String, Hash, Symbol, nil] RGB hex string (e.g. "FF0000"), theme/indexed hash, or nil.
|
|
1591
|
-
# @param opts [Hash] Color keyword arguments (e.g. theme: 1, tint: 0.5, indexed: 9, auto: true).
|
|
1592
|
-
# @return [String, Hash, nil]
|
|
1378
|
+
# @return [String, Hash, nil]
|
|
1593
1379
|
# @api public
|
|
1594
|
-
#: (
|
|
1595
|
-
def tab_color
|
|
1596
|
-
|
|
1597
|
-
@sheet_properties[:tab_color]
|
|
1598
|
-
else
|
|
1599
|
-
color = if opts.empty?
|
|
1600
|
-
spec
|
|
1601
|
-
else
|
|
1602
|
-
spec.is_a?(Hash) ? spec.merge(opts) : opts
|
|
1603
|
-
end
|
|
1604
|
-
@sheet_properties[:tab_color] = color
|
|
1605
|
-
end
|
|
1380
|
+
#: () -> (String | Hash[Symbol, untyped] | nil)
|
|
1381
|
+
def tab_color
|
|
1382
|
+
@sheet_properties[:tab_color]
|
|
1606
1383
|
end
|
|
1607
1384
|
|
|
1608
1385
|
# Sets the tab color of this worksheet.
|
|
@@ -1617,48 +1394,32 @@ module Xlsxrb
|
|
|
1617
1394
|
|
|
1618
1395
|
# Sets a single sheet property.
|
|
1619
1396
|
#
|
|
1620
|
-
# @param name [Symbol, String] Property name.
|
|
1621
|
-
# @param value [Object] Property value.
|
|
1622
|
-
# @return [void]
|
|
1623
|
-
# @api public
|
|
1624
|
-
#: (Symbol | String name, untyped value) -> void
|
|
1625
|
-
def sheet_property(name, value)
|
|
1626
|
-
sheet_properties(name, value)
|
|
1627
|
-
end
|
|
1628
|
-
|
|
1629
1397
|
# Configures or queries sheet properties (<sheetPr>).
|
|
1630
1398
|
#
|
|
1631
1399
|
# When called with no arguments, returns the {Elements::SheetProperties} value object.
|
|
1632
|
-
# When called with
|
|
1400
|
+
# When called with keyword options, configures properties and returns nil.
|
|
1633
1401
|
#
|
|
1634
|
-
# @param name [Symbol, String, Hash, Elements::MetadataRecord, nil] Property name or hash/record of properties.
|
|
1635
|
-
# @param value [Object, nil] Property value when name is provided.
|
|
1636
1402
|
# @param opts [Hash] Additional sheet properties.
|
|
1637
1403
|
# @return [Elements::SheetProperties, void]
|
|
1638
1404
|
# @api public
|
|
1639
|
-
#: (
|
|
1640
|
-
|
|
1641
|
-
|
|
1405
|
+
#: () -> Elements::SheetProperties
|
|
1406
|
+
#: (**untyped opts) -> void
|
|
1407
|
+
def sheet_properties(**opts)
|
|
1408
|
+
return Elements::SheetProperties.new(**@sheet_properties) if opts.empty?
|
|
1642
1409
|
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
name = nil
|
|
1646
|
-
end
|
|
1647
|
-
if name && !value.nil?
|
|
1648
|
-
sym = name.to_sym
|
|
1410
|
+
opts.each do |k, v|
|
|
1411
|
+
sym = k.to_sym
|
|
1649
1412
|
if sym == :state
|
|
1650
|
-
val =
|
|
1413
|
+
val = v.to_sym
|
|
1651
1414
|
raise ArgumentError, "Invalid sheet state ':#{val}'. Allowed states are :visible, :hidden, :very_hidden" unless VALID_SHEET_STATES.include?(val)
|
|
1652
1415
|
|
|
1653
1416
|
@state = val
|
|
1654
|
-
return nil
|
|
1655
1417
|
elsif sym == :hidden
|
|
1656
|
-
@state =
|
|
1657
|
-
|
|
1418
|
+
@state = v ? :hidden : :visible
|
|
1419
|
+
else
|
|
1420
|
+
@sheet_properties[sym] = v
|
|
1658
1421
|
end
|
|
1659
|
-
@sheet_properties[name.to_sym] = value
|
|
1660
1422
|
end
|
|
1661
|
-
opts.each { |k, v| sheet_properties(k, v) }
|
|
1662
1423
|
nil
|
|
1663
1424
|
end
|
|
1664
1425
|
|
|
@@ -1671,29 +1432,23 @@ module Xlsxrb
|
|
|
1671
1432
|
def sheet_properties=(opts)
|
|
1672
1433
|
h = opts.respond_to?(:to_h) ? opts.to_h : (opts || {})
|
|
1673
1434
|
@sheet_properties = {}
|
|
1674
|
-
|
|
1435
|
+
sheet_properties(**h)
|
|
1675
1436
|
nil
|
|
1676
1437
|
end
|
|
1677
1438
|
|
|
1678
1439
|
# Configures or queries sheet view display properties (<sheetView>).
|
|
1679
1440
|
#
|
|
1680
1441
|
# When called with no arguments, returns the {Elements::SheetView} value object.
|
|
1681
|
-
# When called with
|
|
1442
|
+
# When called with keyword options, configures view properties and returns nil.
|
|
1682
1443
|
#
|
|
1683
|
-
# @param name [Symbol, String, Hash, Elements::MetadataRecord, nil] View property name or hash/record of properties.
|
|
1684
|
-
# @param value [Object, nil] View property value when name is provided.
|
|
1685
1444
|
# @param opts [Hash] Additional view properties.
|
|
1686
1445
|
# @return [Elements::SheetView, void]
|
|
1687
1446
|
# @api public
|
|
1688
|
-
#: (
|
|
1689
|
-
|
|
1690
|
-
|
|
1447
|
+
#: () -> Elements::SheetView
|
|
1448
|
+
#: (**untyped opts) -> void
|
|
1449
|
+
def sheet_view(**opts)
|
|
1450
|
+
return Elements::SheetView.new(**@sheet_view) if opts.empty?
|
|
1691
1451
|
|
|
1692
|
-
if name.is_a?(Hash) || (name.respond_to?(:to_h) && !name.is_a?(Symbol) && !name.is_a?(String))
|
|
1693
|
-
opts = name.to_h.merge(opts)
|
|
1694
|
-
name = nil
|
|
1695
|
-
end
|
|
1696
|
-
@sheet_view[name.to_sym] = value if name && !value.nil?
|
|
1697
1452
|
opts.each { |k, v| @sheet_view[k.to_sym] = v }
|
|
1698
1453
|
nil
|
|
1699
1454
|
end
|
|
@@ -1713,41 +1468,20 @@ module Xlsxrb
|
|
|
1713
1468
|
# Configures or queries sheet format properties (<sheetFormatPr>).
|
|
1714
1469
|
#
|
|
1715
1470
|
# When called with no arguments, returns the {Elements::SheetFormat} value object.
|
|
1716
|
-
# When called with
|
|
1471
|
+
# When called with keyword options, configures format properties and returns nil.
|
|
1717
1472
|
#
|
|
1718
1473
|
# @example Using keyword arguments
|
|
1719
1474
|
# sheet.sheet_format(default_row_height: 24, default_column_width: 15)
|
|
1720
1475
|
#
|
|
1721
|
-
# @example Using property name and value
|
|
1722
|
-
# sheet.sheet_format(:default_row_height, 24)
|
|
1723
|
-
#
|
|
1724
|
-
# @param name [Symbol, String, Hash, Elements::MetadataRecord, nil] Property name or hash/record of properties.
|
|
1725
|
-
# @param value [Object, nil] Property value when name is provided.
|
|
1726
1476
|
# @param opts [Hash] Keyword arguments for sheet format properties.
|
|
1727
1477
|
# @return [Elements::SheetFormat, void]
|
|
1728
1478
|
# @api public
|
|
1729
|
-
#: (
|
|
1730
|
-
|
|
1731
|
-
|
|
1479
|
+
#: () -> Elements::SheetFormat
|
|
1480
|
+
#: (**untyped opts) -> void
|
|
1481
|
+
def sheet_format(**opts)
|
|
1482
|
+
return Elements::SheetFormat.new(**@sheet_format) if opts.empty?
|
|
1732
1483
|
|
|
1733
|
-
|
|
1734
|
-
@sheet_format.merge!(name.to_h)
|
|
1735
|
-
elsif name && value
|
|
1736
|
-
@sheet_format[name.to_sym] = value
|
|
1737
|
-
end
|
|
1738
|
-
if opts.key?(:default_col_width) && !opts.key?(:default_column_width)
|
|
1739
|
-
warn "[DEPRECATION] `default_col_width:` is deprecated; use `default_column_width:` instead.", uplevel: 1
|
|
1740
|
-
opts[:default_column_width] = opts[:default_col_width]
|
|
1741
|
-
end
|
|
1742
|
-
if opts.key?(:base_col_width) && !opts.key?(:base_column_width)
|
|
1743
|
-
warn "[DEPRECATION] `base_col_width:` is deprecated; use `base_column_width:` instead.", uplevel: 1
|
|
1744
|
-
opts[:base_column_width] = opts[:base_col_width]
|
|
1745
|
-
end
|
|
1746
|
-
if opts.key?(:outline_level_col) && !opts.key?(:outline_level_column)
|
|
1747
|
-
warn "[DEPRECATION] `outline_level_col:` is deprecated; use `outline_level_column:` instead.", uplevel: 1
|
|
1748
|
-
opts[:outline_level_column] = opts[:outline_level_col]
|
|
1749
|
-
end
|
|
1750
|
-
@sheet_format.merge!(opts) unless opts.empty?
|
|
1484
|
+
opts.each { |k, v| @sheet_format[k.to_sym] = v }
|
|
1751
1485
|
nil
|
|
1752
1486
|
end
|
|
1753
1487
|
|
|
@@ -1759,8 +1493,7 @@ module Xlsxrb
|
|
|
1759
1493
|
#: (Hash[Symbol, untyped] | Elements::SheetFormat opts) -> void
|
|
1760
1494
|
def sheet_format=(opts)
|
|
1761
1495
|
h = opts.respond_to?(:to_h) ? opts.to_h : (opts || {})
|
|
1762
|
-
@sheet_format =
|
|
1763
|
-
sheet_format(h)
|
|
1496
|
+
@sheet_format = h.transform_keys(&:to_sym)
|
|
1764
1497
|
nil
|
|
1765
1498
|
end
|
|
1766
1499
|
|
|
@@ -1774,13 +1507,6 @@ module Xlsxrb
|
|
|
1774
1507
|
@row_breaks << { id: row_index, max: 16_383, man: 1 }
|
|
1775
1508
|
end
|
|
1776
1509
|
|
|
1777
|
-
# @deprecated Use {#row_break} instead.
|
|
1778
|
-
#: (Integer row_num) -> void
|
|
1779
|
-
def page_break_row(row_num)
|
|
1780
|
-
warn "[DEPRECATION] `page_break_row` is deprecated; use `row_break` instead.", uplevel: 1
|
|
1781
|
-
row_break(row_num)
|
|
1782
|
-
end
|
|
1783
|
-
|
|
1784
1510
|
# Inserts a vertical page break after the specified column.
|
|
1785
1511
|
#
|
|
1786
1512
|
# @param col [Integer, String, Symbol] Column index (0-based) or letter ("B", :B).
|
|
@@ -1792,13 +1518,6 @@ module Xlsxrb
|
|
|
1792
1518
|
@col_breaks << { id: col_index, max: 1_048_575, man: 1 }
|
|
1793
1519
|
end
|
|
1794
1520
|
|
|
1795
|
-
# @deprecated Use {#column_break} instead.
|
|
1796
|
-
#: (Integer | String | Symbol col_index) -> void
|
|
1797
|
-
def page_break_col(col_index)
|
|
1798
|
-
warn "[DEPRECATION] `page_break_col` is deprecated; use `column_break` instead.", uplevel: 1
|
|
1799
|
-
column_break(col_index)
|
|
1800
|
-
end
|
|
1801
|
-
|
|
1802
1521
|
# Adds a protected range to the worksheet.
|
|
1803
1522
|
#
|
|
1804
1523
|
# @param name [String] Name of the protected range.
|
|
@@ -1814,8 +1533,6 @@ module Xlsxrb
|
|
|
1814
1533
|
entry.merge!(opts) unless opts.empty?
|
|
1815
1534
|
@protected_ranges << DslHelpers.normalize_protection_options(entry)
|
|
1816
1535
|
end
|
|
1817
|
-
# @deprecated Use {#protected_range} instead. Will be removed in 0.2.0.
|
|
1818
|
-
alias add_protected_range protected_range
|
|
1819
1536
|
|
|
1820
1537
|
# Adds a cell watch to the worksheet.
|
|
1821
1538
|
#
|
|
@@ -1826,8 +1543,6 @@ module Xlsxrb
|
|
|
1826
1543
|
def cell_watch(ref)
|
|
1827
1544
|
@cell_watches << ref.to_s
|
|
1828
1545
|
end
|
|
1829
|
-
# @deprecated Use {#cell_watch} instead. Will be removed in 0.2.0.
|
|
1830
|
-
alias add_cell_watch cell_watch
|
|
1831
1546
|
|
|
1832
1547
|
# Adds an ignored error entry for the worksheet.
|
|
1833
1548
|
#
|
|
@@ -1840,65 +1555,25 @@ module Xlsxrb
|
|
|
1840
1555
|
@ignored_errors << { sqref: sqref.to_s }.merge(opts)
|
|
1841
1556
|
end
|
|
1842
1557
|
|
|
1843
|
-
# @deprecated Use {#ignored_error} instead. Will be removed in 0.2.0.
|
|
1844
|
-
#: (String sqref, ?eval_error: bool, ?two_digit_text_year: bool, ?number_stored_as_text: bool, ?formula: bool, ?formula_range: bool, ?unlocked_formula: bool, ?empty_cell_reference: bool, ?list_data_validation: bool, ?calculated_column: bool) -> void
|
|
1845
|
-
def ignore_error(sqref, **opts)
|
|
1846
|
-
warn "[DEPRECATION] #ignore_error is deprecated; use #ignored_error instead.", uplevel: 1
|
|
1847
|
-
ignored_error(sqref, **opts)
|
|
1848
|
-
end
|
|
1849
|
-
|
|
1850
|
-
# @deprecated Use {#ignored_error} instead. Will be removed in 0.2.0.
|
|
1851
|
-
#: (String sqref, ?eval_error: bool, ?two_digit_text_year: bool, ?number_stored_as_text: bool, ?formula: bool, ?formula_range: bool, ?unlocked_formula: bool, ?empty_cell_reference: bool, ?list_data_validation: bool, ?calculated_column: bool) -> void
|
|
1852
|
-
def add_ignored_error(sqref, **opts)
|
|
1853
|
-
warn "[DEPRECATION] #add_ignored_error is deprecated; use #ignored_error instead.", uplevel: 1
|
|
1854
|
-
ignored_error(sqref, **opts)
|
|
1855
|
-
end
|
|
1856
|
-
|
|
1857
1558
|
# Returns ignored error rules configured for this worksheet.
|
|
1858
1559
|
#
|
|
1859
|
-
# @return [Array<
|
|
1560
|
+
# @return [Array<Elements::IgnoredError>]
|
|
1860
1561
|
# @api public
|
|
1861
|
-
#: () -> Array[
|
|
1562
|
+
#: () -> Array[Elements::IgnoredError]
|
|
1862
1563
|
def ignored_errors
|
|
1863
1564
|
@ignored_errors.map { |ie| ie.is_a?(Elements::IgnoredError) ? ie : Elements::IgnoredError.new(**ie) }.freeze
|
|
1864
1565
|
end
|
|
1865
1566
|
|
|
1866
|
-
# Gets
|
|
1567
|
+
# Gets phonetic (furigana) guide properties for the sheet.
|
|
1867
1568
|
#
|
|
1868
|
-
# @
|
|
1869
|
-
# @overload phonetic_properties()
|
|
1870
|
-
# Returns the current phonetic properties.
|
|
1871
|
-
# @return [Hash, nil]
|
|
1872
|
-
# @overload phonetic_properties(props = nil, font_id: nil, type: nil, alignment: nil)
|
|
1873
|
-
# Sets phonetic properties.
|
|
1874
|
-
# @param spec [Hash, Integer, nil]
|
|
1875
|
-
# @param font_id [Integer, nil]
|
|
1876
|
-
# @param type [Symbol, String, nil]
|
|
1877
|
-
# @param alignment [Symbol, String, nil]
|
|
1878
|
-
# @return [Hash, nil]
|
|
1569
|
+
# @return [Elements::PhoneticProperties, nil]
|
|
1879
1570
|
# @api public
|
|
1880
|
-
#: (
|
|
1881
|
-
def phonetic_properties
|
|
1882
|
-
|
|
1883
|
-
return nil unless @phonetic_properties
|
|
1571
|
+
#: () -> Elements::PhoneticProperties?
|
|
1572
|
+
def phonetic_properties
|
|
1573
|
+
return nil unless @phonetic_properties
|
|
1884
1574
|
|
|
1885
|
-
|
|
1886
|
-
elsif !spec.equal?(OMITTED) && spec.nil? && font_id.nil? && type.nil? && alignment.nil? && opts.empty?
|
|
1887
|
-
@phonetic_properties = nil
|
|
1888
|
-
else
|
|
1889
|
-
props = if spec.is_a?(Hash)
|
|
1890
|
-
spec.merge(opts)
|
|
1891
|
-
elsif spec.is_a?(Integer)
|
|
1892
|
-
{ font_id: spec, type: type, alignment: alignment }.merge(opts)
|
|
1893
|
-
else
|
|
1894
|
-
{ font_id: font_id, type: type, alignment: alignment }.merge(opts)
|
|
1895
|
-
end
|
|
1896
|
-
props.compact!
|
|
1897
|
-
@phonetic_properties = WorksheetBuilder.normalize_phonetic_properties(props)
|
|
1898
|
-
end
|
|
1575
|
+
@phonetic_properties.is_a?(Elements::PhoneticProperties) ? @phonetic_properties : Elements::PhoneticProperties.new(**@phonetic_properties)
|
|
1899
1576
|
end
|
|
1900
|
-
# @deprecated Use {#phonetic_properties} instead. Will be removed in 0.2.0.
|
|
1901
|
-
alias phonetic_pr phonetic_properties
|
|
1902
1577
|
|
|
1903
1578
|
# Sets phonetic (furigana) guide properties for the sheet.
|
|
1904
1579
|
#
|
|
@@ -1921,8 +1596,6 @@ module Xlsxrb
|
|
|
1921
1596
|
end
|
|
1922
1597
|
spec
|
|
1923
1598
|
end
|
|
1924
|
-
# @deprecated Use {#phonetic_properties=} instead. Will be removed in 0.2.0.
|
|
1925
|
-
alias phonetic_pr= phonetic_properties=
|
|
1926
1599
|
|
|
1927
1600
|
# Normalizes phonetic properties to OOXML schema values.
|
|
1928
1601
|
#
|
|
@@ -1958,17 +1631,13 @@ module Xlsxrb
|
|
|
1958
1631
|
res
|
|
1959
1632
|
end
|
|
1960
1633
|
|
|
1961
|
-
#
|
|
1634
|
+
# Gets the internal code name of the worksheet.
|
|
1962
1635
|
#
|
|
1963
|
-
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#code_name=} instead.
|
|
1964
|
-
# @param val [String, Symbol, nil] The code name.
|
|
1965
1636
|
# @return [String, nil]
|
|
1966
1637
|
# @api public
|
|
1967
|
-
#: (
|
|
1968
|
-
def code_name
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
@sheet_properties[:code_name] = val&.to_s
|
|
1638
|
+
#: () -> String?
|
|
1639
|
+
def code_name
|
|
1640
|
+
@sheet_properties[:code_name]
|
|
1972
1641
|
end
|
|
1973
1642
|
|
|
1974
1643
|
# Sets the internal code name of the worksheet.
|
|
@@ -1981,36 +1650,16 @@ module Xlsxrb
|
|
|
1981
1650
|
@sheet_properties[:code_name] = val&.to_s
|
|
1982
1651
|
end
|
|
1983
1652
|
|
|
1984
|
-
#
|
|
1985
|
-
#
|
|
1986
|
-
# @example Instruct Excel to recalculate formulas when loading sheet
|
|
1987
|
-
# sheet.sheet_calc_properties = { full_calc_on_load: true }
|
|
1653
|
+
# Gets worksheet calculation properties (<sheetCalcPr>).
|
|
1988
1654
|
#
|
|
1989
|
-
# @
|
|
1990
|
-
# @param spec [Hash, nil] Calculation properties hash.
|
|
1991
|
-
# @param full_calc_on_load [Boolean, nil] Whether to recalculate when loading.
|
|
1992
|
-
# @return [Hash, nil]
|
|
1655
|
+
# @return [Elements::SheetCalcProperties, nil]
|
|
1993
1656
|
# @api public
|
|
1994
|
-
#: (
|
|
1995
|
-
def sheet_calc_properties
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
return nil unless calc
|
|
1999
|
-
|
|
2000
|
-
return calc.is_a?(Elements::SheetCalcProperties) ? calc : Elements::SheetCalcProperties.new(**calc)
|
|
2001
|
-
end
|
|
2002
|
-
|
|
2003
|
-
warn "[DEPRECATION] Calling #sheet_calc_properties with arguments is deprecated and will be removed in 0.2.0. Use #sheet_calc_properties= instead.", uplevel: 1
|
|
2004
|
-
if !spec.equal?(OMITTED) && spec.nil? && full_calc_on_load.nil? && opts.empty?
|
|
2005
|
-
@sheet_properties.delete(:full_calc_on_load)
|
|
2006
|
-
return @sheet_calc_pr = nil
|
|
2007
|
-
end
|
|
1657
|
+
#: () -> Elements::SheetCalcProperties?
|
|
1658
|
+
def sheet_calc_properties
|
|
1659
|
+
calc = @sheet_calc_pr || (@sheet_properties[:full_calc_on_load] ? { full_calc_on_load: true } : nil)
|
|
1660
|
+
return nil unless calc
|
|
2008
1661
|
|
|
2009
|
-
|
|
2010
|
-
pr[:full_calc_on_load] = full_calc_on_load unless full_calc_on_load.nil?
|
|
2011
|
-
pr.merge!(opts) unless opts.empty?
|
|
2012
|
-
@sheet_properties[:full_calc_on_load] = pr[:full_calc_on_load] unless pr[:full_calc_on_load].nil?
|
|
2013
|
-
@sheet_calc_pr = pr
|
|
1662
|
+
calc.is_a?(Elements::SheetCalcProperties) ? calc : Elements::SheetCalcProperties.new(**calc)
|
|
2014
1663
|
end
|
|
2015
1664
|
|
|
2016
1665
|
# Sets worksheet calculation properties (<sheetCalcPr>).
|
|
@@ -2031,34 +1680,6 @@ module Xlsxrb
|
|
|
2031
1680
|
spec
|
|
2032
1681
|
end
|
|
2033
1682
|
|
|
2034
|
-
# @deprecated Use {#sheet_calc_properties} instead. Will be removed in 0.2.0.
|
|
2035
|
-
#: (?Hash[Symbol, untyped]? spec, ?full_calc_on_load: bool?, **untyped opts) -> (Elements::SheetCalcProperties | Hash[Symbol, untyped] | nil)
|
|
2036
|
-
def sheet_calc_pr(spec = OMITTED, full_calc_on_load: nil, **opts)
|
|
2037
|
-
warn "[DEPRECATION] #sheet_calc_pr is deprecated; use #sheet_calc_properties instead.", uplevel: 1
|
|
2038
|
-
sheet_calc_properties(spec, full_calc_on_load: full_calc_on_load, **opts)
|
|
2039
|
-
end
|
|
2040
|
-
|
|
2041
|
-
# @deprecated Use {#sheet_calc_properties} instead. Will be removed in 0.2.0.
|
|
2042
|
-
#: (?Hash[Symbol, untyped]? spec, ?full_calc_on_load: bool?, **untyped opts) -> (Elements::SheetCalcProperties | Hash[Symbol, untyped] | nil)
|
|
2043
|
-
def calc_pr(spec = OMITTED, full_calc_on_load: nil, **opts)
|
|
2044
|
-
warn "[DEPRECATION] #calc_pr is deprecated; use #sheet_calc_properties instead.", uplevel: 1
|
|
2045
|
-
sheet_calc_properties(spec, full_calc_on_load: full_calc_on_load, **opts)
|
|
2046
|
-
end
|
|
2047
|
-
|
|
2048
|
-
# @deprecated Use {#sheet_calc_properties=} instead. Will be removed in 0.2.0.
|
|
2049
|
-
#: (Hash[Symbol, untyped]? spec) -> Hash[Symbol, untyped]?
|
|
2050
|
-
def sheet_calc_pr=(spec)
|
|
2051
|
-
warn "[DEPRECATION] #sheet_calc_pr= is deprecated; use #sheet_calc_properties= instead.", uplevel: 1
|
|
2052
|
-
self.sheet_calc_properties = spec
|
|
2053
|
-
end
|
|
2054
|
-
|
|
2055
|
-
# @deprecated Use {#sheet_calc_properties=} instead. Will be removed in 0.2.0.
|
|
2056
|
-
#: (Hash[Symbol, untyped]? spec) -> Hash[Symbol, untyped]?
|
|
2057
|
-
def calc_pr=(spec)
|
|
2058
|
-
warn "[DEPRECATION] #calc_pr= is deprecated; use #sheet_calc_properties= instead.", uplevel: 1
|
|
2059
|
-
self.sheet_calc_properties = spec
|
|
2060
|
-
end
|
|
2061
|
-
|
|
2062
1683
|
# Builds and returns the in-memory {Elements::Worksheet}.
|
|
2063
1684
|
#
|
|
2064
1685
|
# @return [Elements::Worksheet]
|
|
@@ -2092,7 +1713,7 @@ module Xlsxrb
|
|
|
2092
1713
|
facade_meta[:sheet_format] = @sheet_format unless @sheet_format.empty?
|
|
2093
1714
|
facade_meta[:sheet_view] = @sheet_view unless @sheet_view.empty?
|
|
2094
1715
|
facade_meta[:row_breaks] = @row_breaks unless @row_breaks.empty?
|
|
2095
|
-
facade_meta[:
|
|
1716
|
+
facade_meta[:column_breaks] = @col_breaks unless @col_breaks.empty?
|
|
2096
1717
|
facade_meta[:protected_ranges] = @protected_ranges unless @protected_ranges.empty?
|
|
2097
1718
|
facade_meta[:cell_watches] = @cell_watches unless @cell_watches.empty?
|
|
2098
1719
|
facade_meta[:ignored_errors] = @ignored_errors unless @ignored_errors.empty?
|
|
@@ -2105,11 +1726,8 @@ module Xlsxrb
|
|
|
2105
1726
|
hl_hash = {}
|
|
2106
1727
|
@hyperlinks.each do |h|
|
|
2107
1728
|
if h.is_a?(Elements::Hyperlink)
|
|
2108
|
-
ref_val = if h.respond_to?(:
|
|
2109
|
-
|
|
2110
|
-
elsif h.respond_to?(:ref)
|
|
2111
|
-
h.ref
|
|
2112
|
-
end
|
|
1729
|
+
ref_val = h.ref if h.respond_to?(:ref)
|
|
1730
|
+
ref_val ||= h.cell if h.respond_to?(:cell)
|
|
2113
1731
|
ref = ref_val.to_s.upcase
|
|
2114
1732
|
hl_hash[ref] = h unless ref.empty?
|
|
2115
1733
|
else
|
|
@@ -2126,14 +1744,14 @@ module Xlsxrb
|
|
|
2126
1744
|
cm_hash = {}
|
|
2127
1745
|
@comments.each do |c|
|
|
2128
1746
|
obj = c.is_a?(Elements::Comment) ? c : Elements::Comment.new(**c)
|
|
2129
|
-
ref = obj.ref.to_s.upcase
|
|
1747
|
+
ref = (obj.respond_to?(:ref) ? obj.ref : obj[:ref]).to_s.upcase
|
|
2130
1748
|
cm_hash[ref] = obj
|
|
2131
1749
|
end
|
|
2132
1750
|
|
|
2133
1751
|
tc_hash = {}
|
|
2134
1752
|
@threaded_comments.each do |c|
|
|
2135
1753
|
obj = c.is_a?(Elements::ThreadedComment) ? c : Elements::ThreadedComment.new(**c)
|
|
2136
|
-
ref = obj.ref.to_s.upcase
|
|
1754
|
+
ref = (obj.respond_to?(:ref) ? obj.ref : obj[:ref]).to_s.upcase
|
|
2137
1755
|
(tc_hash[ref] ||= []) << obj
|
|
2138
1756
|
end
|
|
2139
1757
|
|
|
@@ -2176,6 +1794,9 @@ module Xlsxrb
|
|
|
2176
1794
|
tables: @tables,
|
|
2177
1795
|
shapes: @shapes,
|
|
2178
1796
|
freeze_pane: @freeze_pane,
|
|
1797
|
+
split_pane: @split_pane,
|
|
1798
|
+
filter_columns: @filter_columns,
|
|
1799
|
+
sort_state: @sort_state,
|
|
2179
1800
|
page_setup: @page_setup,
|
|
2180
1801
|
page_margins: @page_margins,
|
|
2181
1802
|
header_footer: @header_footer,
|
|
@@ -2206,8 +1827,6 @@ module Xlsxrb
|
|
|
2206
1827
|
#
|
|
2207
1828
|
# @api public
|
|
2208
1829
|
class TableBuilder
|
|
2209
|
-
OMITTED = Object.new.freeze
|
|
2210
|
-
private_constant :OMITTED
|
|
2211
1830
|
# @param ref [String, nil] Table range (e.g. "A1:D10").
|
|
2212
1831
|
# @param columns [Array, nil] Column header names or definition hashes.
|
|
2213
1832
|
# @param name [String, nil] Table name identifier.
|
|
@@ -2224,28 +1843,9 @@ module Xlsxrb
|
|
|
2224
1843
|
@options[:style] = style if style
|
|
2225
1844
|
end
|
|
2226
1845
|
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
warn "[Xlsxrb DEPRECATION] TableBuilder#[] is deprecated and will be removed in v0.2.0. Use explicit getter methods instead.", uplevel: 1
|
|
2231
|
-
@options[key.to_sym]
|
|
2232
|
-
end
|
|
2233
|
-
|
|
2234
|
-
# @deprecated Use explicit setter methods instead.
|
|
2235
|
-
#: (untyped key, untyped value) -> untyped
|
|
2236
|
-
def []=(key, value)
|
|
2237
|
-
warn "[Xlsxrb DEPRECATION] TableBuilder#[]= is deprecated and will be removed in v0.2.0. Use explicit setter methods instead.", uplevel: 1
|
|
2238
|
-
@options[key.to_sym] = value
|
|
2239
|
-
end
|
|
2240
|
-
|
|
2241
|
-
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#ref=} instead.
|
|
2242
|
-
#: (?String? val) -> String?
|
|
2243
|
-
def ref(val = nil)
|
|
2244
|
-
if val
|
|
2245
|
-
@options[:ref] = val.to_s
|
|
2246
|
-
else
|
|
2247
|
-
@options[:ref]
|
|
2248
|
-
end
|
|
1846
|
+
#: () -> String?
|
|
1847
|
+
def ref
|
|
1848
|
+
@options[:ref]
|
|
2249
1849
|
end
|
|
2250
1850
|
|
|
2251
1851
|
#: (String val) -> String
|
|
@@ -2253,15 +1853,20 @@ module Xlsxrb
|
|
|
2253
1853
|
@options[:ref] = val.to_s
|
|
2254
1854
|
end
|
|
2255
1855
|
|
|
2256
|
-
#
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
1856
|
+
# Returns column definitions for the table.
|
|
1857
|
+
#
|
|
1858
|
+
# @return [Array<Elements::TableColumn>]
|
|
1859
|
+
# @api public
|
|
1860
|
+
#: () -> Array[Elements::TableColumn]
|
|
1861
|
+
def columns
|
|
1862
|
+
(@options[:columns] || []).each_with_index.map do |c, idx|
|
|
1863
|
+
if c.is_a?(Elements::TableColumn)
|
|
1864
|
+
c
|
|
1865
|
+
elsif c.is_a?(Hash)
|
|
1866
|
+
Elements::TableColumn.new(id: idx + 1, **c)
|
|
1867
|
+
else
|
|
1868
|
+
Elements::TableColumn.new(id: idx + 1, name: c.to_s)
|
|
1869
|
+
end
|
|
2265
1870
|
end
|
|
2266
1871
|
end
|
|
2267
1872
|
|
|
@@ -2287,8 +1892,6 @@ module Xlsxrb
|
|
|
2287
1892
|
(@options[:columns] ||= []) << col_spec
|
|
2288
1893
|
nil
|
|
2289
1894
|
end
|
|
2290
|
-
# @deprecated Use {#column} instead. Will be removed in 0.2.0.
|
|
2291
|
-
alias add_column column
|
|
2292
1895
|
|
|
2293
1896
|
# Appends a calculated column with formula and options.
|
|
2294
1897
|
#
|
|
@@ -2301,14 +1904,9 @@ module Xlsxrb
|
|
|
2301
1904
|
column(name, formula: formula, **opts)
|
|
2302
1905
|
end
|
|
2303
1906
|
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
if val
|
|
2308
|
-
@options[:name] = val.to_s
|
|
2309
|
-
else
|
|
2310
|
-
@options[:name]
|
|
2311
|
-
end
|
|
1907
|
+
#: () -> String?
|
|
1908
|
+
def name
|
|
1909
|
+
@options[:name]
|
|
2312
1910
|
end
|
|
2313
1911
|
|
|
2314
1912
|
#: (String val) -> String
|
|
@@ -2316,14 +1914,9 @@ module Xlsxrb
|
|
|
2316
1914
|
@options[:name] = val.to_s
|
|
2317
1915
|
end
|
|
2318
1916
|
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
if val
|
|
2323
|
-
@options[:display_name] = val.to_s
|
|
2324
|
-
else
|
|
2325
|
-
@options[:display_name]
|
|
2326
|
-
end
|
|
1917
|
+
#: () -> String?
|
|
1918
|
+
def display_name
|
|
1919
|
+
@options[:display_name]
|
|
2327
1920
|
end
|
|
2328
1921
|
|
|
2329
1922
|
#: (String val) -> String
|
|
@@ -2331,14 +1924,9 @@ module Xlsxrb
|
|
|
2331
1924
|
@options[:display_name] = val.to_s
|
|
2332
1925
|
end
|
|
2333
1926
|
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
if val
|
|
2338
|
-
@options[:style] = val.to_s
|
|
2339
|
-
else
|
|
2340
|
-
@options[:style]
|
|
2341
|
-
end
|
|
1927
|
+
#: () -> String?
|
|
1928
|
+
def style
|
|
1929
|
+
@options[:style]
|
|
2342
1930
|
end
|
|
2343
1931
|
|
|
2344
1932
|
#: (String val) -> String
|
|
@@ -2346,14 +1934,9 @@ module Xlsxrb
|
|
|
2346
1934
|
@options[:style] = val.to_s
|
|
2347
1935
|
end
|
|
2348
1936
|
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
if val.nil?
|
|
2353
|
-
@options[:show_row_stripes]
|
|
2354
|
-
else
|
|
2355
|
-
@options[:show_row_stripes] = val ? true : false
|
|
2356
|
-
end
|
|
1937
|
+
#: () -> bool
|
|
1938
|
+
def show_row_stripes?
|
|
1939
|
+
@options[:show_row_stripes] ? true : false
|
|
2357
1940
|
end
|
|
2358
1941
|
|
|
2359
1942
|
#: (bool val) -> bool
|
|
@@ -2361,14 +1944,9 @@ module Xlsxrb
|
|
|
2361
1944
|
@options[:show_row_stripes] = val ? true : false
|
|
2362
1945
|
end
|
|
2363
1946
|
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
if val.nil?
|
|
2368
|
-
@options[:show_column_stripes]
|
|
2369
|
-
else
|
|
2370
|
-
@options[:show_column_stripes] = val ? true : false
|
|
2371
|
-
end
|
|
1947
|
+
#: () -> bool
|
|
1948
|
+
def show_column_stripes?
|
|
1949
|
+
@options[:show_column_stripes] ? true : false
|
|
2372
1950
|
end
|
|
2373
1951
|
|
|
2374
1952
|
#: (bool val) -> bool
|
|
@@ -2376,14 +1954,9 @@ module Xlsxrb
|
|
|
2376
1954
|
@options[:show_column_stripes] = val ? true : false
|
|
2377
1955
|
end
|
|
2378
1956
|
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
if val.nil?
|
|
2383
|
-
@options[:show_first_column]
|
|
2384
|
-
else
|
|
2385
|
-
@options[:show_first_column] = val ? true : false
|
|
2386
|
-
end
|
|
1957
|
+
#: () -> bool
|
|
1958
|
+
def show_first_column?
|
|
1959
|
+
@options[:show_first_column] ? true : false
|
|
2387
1960
|
end
|
|
2388
1961
|
|
|
2389
1962
|
#: (bool val) -> bool
|
|
@@ -2391,14 +1964,9 @@ module Xlsxrb
|
|
|
2391
1964
|
@options[:show_first_column] = val ? true : false
|
|
2392
1965
|
end
|
|
2393
1966
|
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
if val.nil?
|
|
2398
|
-
@options[:show_last_column]
|
|
2399
|
-
else
|
|
2400
|
-
@options[:show_last_column] = val ? true : false
|
|
2401
|
-
end
|
|
1967
|
+
#: () -> bool
|
|
1968
|
+
def show_last_column?
|
|
1969
|
+
@options[:show_last_column] ? true : false
|
|
2402
1970
|
end
|
|
2403
1971
|
|
|
2404
1972
|
#: (bool val) -> bool
|
|
@@ -2406,14 +1974,9 @@ module Xlsxrb
|
|
|
2406
1974
|
@options[:show_last_column] = val ? true : false
|
|
2407
1975
|
end
|
|
2408
1976
|
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
if val.nil?
|
|
2413
|
-
@options[:totals_row_count] || @options[:total_row_count]
|
|
2414
|
-
else
|
|
2415
|
-
@options[:totals_row_count] = val.to_i
|
|
2416
|
-
end
|
|
1977
|
+
#: () -> Integer?
|
|
1978
|
+
def totals_row_count
|
|
1979
|
+
@options[:totals_row_count]
|
|
2417
1980
|
end
|
|
2418
1981
|
|
|
2419
1982
|
#: (Integer val) -> Integer
|
|
@@ -2421,31 +1984,16 @@ module Xlsxrb
|
|
|
2421
1984
|
@options[:totals_row_count] = val.to_i
|
|
2422
1985
|
end
|
|
2423
1986
|
|
|
2424
|
-
#
|
|
2425
|
-
#: (?Integer? val) -> Integer?
|
|
2426
|
-
def total_row_count(val = nil)
|
|
2427
|
-
warn "[DEPRECATION] #total_row_count is deprecated; use #totals_row_count instead.", uplevel: 1
|
|
2428
|
-
totals_row_count(val)
|
|
2429
|
-
end
|
|
2430
|
-
|
|
2431
|
-
# @deprecated Use {#totals_row_count=} instead. Will be removed in 0.2.0.
|
|
2432
|
-
#: (Integer val) -> Integer
|
|
2433
|
-
def total_row_count=(val)
|
|
2434
|
-
warn "[DEPRECATION] #total_row_count= is deprecated; use #totals_row_count= instead.", uplevel: 1
|
|
2435
|
-
self.totals_row_count = val
|
|
2436
|
-
end
|
|
2437
|
-
|
|
2438
|
-
# Gets or sets whether the table has a totals row.
|
|
1987
|
+
# Returns whether the table has a totals row.
|
|
2439
1988
|
#
|
|
2440
|
-
# @
|
|
2441
|
-
#: (
|
|
2442
|
-
def totals_row
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
rc
|
|
1989
|
+
# @return [Boolean]
|
|
1990
|
+
#: () -> bool
|
|
1991
|
+
def totals_row?
|
|
1992
|
+
rc = @options[:totals_row_count]
|
|
1993
|
+
if rc
|
|
1994
|
+
rc.positive?
|
|
2446
1995
|
else
|
|
2447
|
-
@options[:
|
|
2448
|
-
val ? true : false
|
|
1996
|
+
@options[:totals_row] ? true : false
|
|
2449
1997
|
end
|
|
2450
1998
|
end
|
|
2451
1999
|
|
|
@@ -2455,28 +2003,9 @@ module Xlsxrb
|
|
|
2455
2003
|
val
|
|
2456
2004
|
end
|
|
2457
2005
|
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
warn "[DEPRECATION] #total_row is deprecated; use #totals_row instead.", uplevel: 1
|
|
2462
|
-
totals_row(val)
|
|
2463
|
-
end
|
|
2464
|
-
|
|
2465
|
-
# @deprecated Use {#totals_row=} instead. Will be removed in 0.2.0.
|
|
2466
|
-
#: (bool val) -> bool
|
|
2467
|
-
def total_row=(val)
|
|
2468
|
-
warn "[DEPRECATION] #total_row= is deprecated; use #totals_row= instead.", uplevel: 1
|
|
2469
|
-
self.totals_row = val
|
|
2470
|
-
end
|
|
2471
|
-
|
|
2472
|
-
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#auto_filter=} instead.
|
|
2473
|
-
#: (?bool? val) -> bool?
|
|
2474
|
-
def auto_filter(val = nil)
|
|
2475
|
-
if val.nil?
|
|
2476
|
-
@options[:auto_filter]
|
|
2477
|
-
else
|
|
2478
|
-
@options[:auto_filter] = val ? true : false
|
|
2479
|
-
end
|
|
2006
|
+
#: () -> bool
|
|
2007
|
+
def auto_filter?
|
|
2008
|
+
@options[:auto_filter] != false
|
|
2480
2009
|
end
|
|
2481
2010
|
|
|
2482
2011
|
#: (bool val) -> bool
|
|
@@ -2502,92 +2031,39 @@ module Xlsxrb
|
|
|
2502
2031
|
@options[:sqref] = sqref if sqref
|
|
2503
2032
|
end
|
|
2504
2033
|
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
# @api public
|
|
2509
|
-
#: (untyped key) -> untyped
|
|
2510
|
-
def [](key)
|
|
2511
|
-
warn "[Xlsxrb DEPRECATION] DataValidationBuilder#[] is deprecated; use dedicated property accessors instead.", uplevel: 1
|
|
2512
|
-
@options[key.to_sym]
|
|
2513
|
-
end
|
|
2514
|
-
|
|
2515
|
-
# @deprecated Use dedicated property accessors instead. Will be removed in 0.2.0.
|
|
2516
|
-
# @param key [Symbol, String]
|
|
2517
|
-
# @param value [Object]
|
|
2518
|
-
# @return [Object]
|
|
2519
|
-
# @api public
|
|
2520
|
-
#: (untyped key, untyped value) -> untyped
|
|
2521
|
-
def []=(key, value)
|
|
2522
|
-
warn "[Xlsxrb DEPRECATION] DataValidationBuilder#[]= is deprecated; use dedicated property accessors instead.", uplevel: 1
|
|
2523
|
-
@options[key.to_sym] = value
|
|
2524
|
-
end
|
|
2525
|
-
|
|
2526
|
-
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#sqref=} instead.
|
|
2527
|
-
#: (?String? val) -> String?
|
|
2528
|
-
def sqref(val = nil)
|
|
2529
|
-
if val
|
|
2530
|
-
@options[:sqref] = val.to_s
|
|
2531
|
-
else
|
|
2532
|
-
@options[:sqref]
|
|
2533
|
-
end
|
|
2034
|
+
#: () -> String?
|
|
2035
|
+
def sqref
|
|
2036
|
+
@options[:sqref]
|
|
2534
2037
|
end
|
|
2535
2038
|
|
|
2536
2039
|
#: (String val) -> String
|
|
2537
2040
|
def sqref=(val)
|
|
2538
2041
|
@options[:sqref] = val.to_s
|
|
2539
2042
|
end
|
|
2540
|
-
# @deprecated Use {#sqref} instead. Will be removed in 0.2.0.
|
|
2541
|
-
alias range sqref
|
|
2542
|
-
# @deprecated Use {#sqref=} instead. Will be removed in 0.2.0.
|
|
2543
|
-
alias range= sqref=
|
|
2544
2043
|
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
if val
|
|
2549
|
-
@options[:columns] = val
|
|
2550
|
-
else
|
|
2551
|
-
@options[:columns]
|
|
2552
|
-
end
|
|
2044
|
+
#: () -> untyped
|
|
2045
|
+
def columns
|
|
2046
|
+
@options[:columns]
|
|
2553
2047
|
end
|
|
2554
2048
|
|
|
2555
2049
|
#: (untyped val) -> untyped
|
|
2556
2050
|
def columns=(val)
|
|
2557
2051
|
@options[:columns] = val
|
|
2558
2052
|
end
|
|
2559
|
-
# @deprecated Use {#columns} instead. Will be removed in 0.2.0.
|
|
2560
|
-
alias col columns
|
|
2561
|
-
# @deprecated Use {#columns=} instead. Will be removed in 0.2.0.
|
|
2562
|
-
alias col= columns=
|
|
2563
2053
|
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
if val
|
|
2568
|
-
@options[:rows] = val
|
|
2569
|
-
else
|
|
2570
|
-
@options[:rows]
|
|
2571
|
-
end
|
|
2054
|
+
#: () -> untyped
|
|
2055
|
+
def rows
|
|
2056
|
+
@options[:rows]
|
|
2572
2057
|
end
|
|
2573
2058
|
|
|
2574
2059
|
#: (untyped val) -> untyped
|
|
2575
2060
|
def rows=(val)
|
|
2576
2061
|
@options[:rows] = val
|
|
2577
2062
|
end
|
|
2578
|
-
# @deprecated Use {#rows} instead. Will be removed in 0.2.0.
|
|
2579
|
-
alias row rows
|
|
2580
|
-
# @deprecated Use {#rows=} instead. Will be removed in 0.2.0.
|
|
2581
|
-
alias row= rows=
|
|
2582
2063
|
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
if val
|
|
2587
|
-
@options[:except_rows] = val
|
|
2588
|
-
else
|
|
2589
|
-
@options[:except_rows]
|
|
2590
|
-
end
|
|
2064
|
+
#: () -> untyped
|
|
2065
|
+
def except_rows
|
|
2066
|
+
@options[:except_rows]
|
|
2591
2067
|
end
|
|
2592
2068
|
|
|
2593
2069
|
#: (untyped val) -> untyped
|
|
@@ -2600,47 +2076,21 @@ module Xlsxrb
|
|
|
2600
2076
|
# @example
|
|
2601
2077
|
# b.list = ["Option1", "Option2"]
|
|
2602
2078
|
#
|
|
2603
|
-
# @param val [Array<Object>, nil]
|
|
2604
2079
|
# @return [Array<Object>, nil]
|
|
2605
2080
|
# @api public
|
|
2606
|
-
#: (
|
|
2607
|
-
def list
|
|
2608
|
-
|
|
2609
|
-
@options[:list] = val
|
|
2610
|
-
@options[:in] = val
|
|
2611
|
-
else
|
|
2612
|
-
@options[:list] || @options[:in]
|
|
2613
|
-
end
|
|
2081
|
+
#: () -> untyped
|
|
2082
|
+
def list
|
|
2083
|
+
@options[:list]
|
|
2614
2084
|
end
|
|
2615
2085
|
|
|
2616
2086
|
#: (Array[untyped] val) -> untyped
|
|
2617
2087
|
def list=(val)
|
|
2618
2088
|
@options[:list] = val
|
|
2619
|
-
@options[:in] = val
|
|
2620
2089
|
end
|
|
2621
2090
|
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
warn "[DEPRECATION] `DataValidationBuilder#in` is deprecated; use `list` instead.", uplevel: 1
|
|
2626
|
-
list(val)
|
|
2627
|
-
end
|
|
2628
|
-
|
|
2629
|
-
# @deprecated Use {#list=} instead.
|
|
2630
|
-
#: (Array[untyped] val) -> untyped
|
|
2631
|
-
def in=(val)
|
|
2632
|
-
warn "[DEPRECATION] `DataValidationBuilder#in=` is deprecated; use `list=` instead.", uplevel: 1
|
|
2633
|
-
self.list = val
|
|
2634
|
-
end
|
|
2635
|
-
|
|
2636
|
-
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#type=} instead.
|
|
2637
|
-
#: (?untyped val) -> untyped
|
|
2638
|
-
def type(val = nil)
|
|
2639
|
-
if val
|
|
2640
|
-
@options[:type] = val
|
|
2641
|
-
else
|
|
2642
|
-
@options[:type]
|
|
2643
|
-
end
|
|
2091
|
+
#: () -> untyped
|
|
2092
|
+
def type
|
|
2093
|
+
@options[:type]
|
|
2644
2094
|
end
|
|
2645
2095
|
|
|
2646
2096
|
#: (untyped val) -> untyped
|
|
@@ -2648,14 +2098,9 @@ module Xlsxrb
|
|
|
2648
2098
|
@options[:type] = val
|
|
2649
2099
|
end
|
|
2650
2100
|
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
if val
|
|
2655
|
-
@options[:operator] = val
|
|
2656
|
-
else
|
|
2657
|
-
@options[:operator]
|
|
2658
|
-
end
|
|
2101
|
+
#: () -> untyped
|
|
2102
|
+
def operator
|
|
2103
|
+
@options[:operator]
|
|
2659
2104
|
end
|
|
2660
2105
|
|
|
2661
2106
|
#: (untyped val) -> untyped
|
|
@@ -2663,14 +2108,9 @@ module Xlsxrb
|
|
|
2663
2108
|
@options[:operator] = val
|
|
2664
2109
|
end
|
|
2665
2110
|
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
if val
|
|
2670
|
-
@options[:formula1] = val
|
|
2671
|
-
else
|
|
2672
|
-
@options[:formula1]
|
|
2673
|
-
end
|
|
2111
|
+
#: () -> untyped
|
|
2112
|
+
def formula1
|
|
2113
|
+
@options[:formula1]
|
|
2674
2114
|
end
|
|
2675
2115
|
|
|
2676
2116
|
#: (untyped val) -> untyped
|
|
@@ -2678,14 +2118,9 @@ module Xlsxrb
|
|
|
2678
2118
|
@options[:formula1] = val
|
|
2679
2119
|
end
|
|
2680
2120
|
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
if val
|
|
2685
|
-
@options[:formula2] = val
|
|
2686
|
-
else
|
|
2687
|
-
@options[:formula2]
|
|
2688
|
-
end
|
|
2121
|
+
#: () -> untyped
|
|
2122
|
+
def formula2
|
|
2123
|
+
@options[:formula2]
|
|
2689
2124
|
end
|
|
2690
2125
|
|
|
2691
2126
|
#: (untyped val) -> untyped
|
|
@@ -2693,14 +2128,9 @@ module Xlsxrb
|
|
|
2693
2128
|
@options[:formula2] = val
|
|
2694
2129
|
end
|
|
2695
2130
|
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
if val.nil?
|
|
2700
|
-
@options[:allow_blank]
|
|
2701
|
-
else
|
|
2702
|
-
@options[:allow_blank] = val ? true : false
|
|
2703
|
-
end
|
|
2131
|
+
#: () -> bool
|
|
2132
|
+
def allow_blank?
|
|
2133
|
+
@options[:allow_blank] ? true : false
|
|
2704
2134
|
end
|
|
2705
2135
|
|
|
2706
2136
|
#: (bool val) -> bool
|
|
@@ -2708,14 +2138,9 @@ module Xlsxrb
|
|
|
2708
2138
|
@options[:allow_blank] = val ? true : false
|
|
2709
2139
|
end
|
|
2710
2140
|
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
if val.nil?
|
|
2715
|
-
@options[:show_input_message]
|
|
2716
|
-
else
|
|
2717
|
-
@options[:show_input_message] = val ? true : false
|
|
2718
|
-
end
|
|
2141
|
+
#: () -> bool
|
|
2142
|
+
def show_input_message?
|
|
2143
|
+
@options[:show_input_message] ? true : false
|
|
2719
2144
|
end
|
|
2720
2145
|
|
|
2721
2146
|
#: (bool val) -> bool
|
|
@@ -2723,14 +2148,9 @@ module Xlsxrb
|
|
|
2723
2148
|
@options[:show_input_message] = val ? true : false
|
|
2724
2149
|
end
|
|
2725
2150
|
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
if val.nil?
|
|
2730
|
-
@options[:show_error_message]
|
|
2731
|
-
else
|
|
2732
|
-
@options[:show_error_message] = val ? true : false
|
|
2733
|
-
end
|
|
2151
|
+
#: () -> bool
|
|
2152
|
+
def show_error_message?
|
|
2153
|
+
@options[:show_error_message] ? true : false
|
|
2734
2154
|
end
|
|
2735
2155
|
|
|
2736
2156
|
#: (bool val) -> bool
|
|
@@ -2738,14 +2158,9 @@ module Xlsxrb
|
|
|
2738
2158
|
@options[:show_error_message] = val ? true : false
|
|
2739
2159
|
end
|
|
2740
2160
|
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
if val
|
|
2745
|
-
@options[:error_title] = val.to_s
|
|
2746
|
-
else
|
|
2747
|
-
@options[:error_title]
|
|
2748
|
-
end
|
|
2161
|
+
#: () -> String?
|
|
2162
|
+
def error_title
|
|
2163
|
+
@options[:error_title]
|
|
2749
2164
|
end
|
|
2750
2165
|
|
|
2751
2166
|
#: (String val) -> String
|
|
@@ -2753,33 +2168,19 @@ module Xlsxrb
|
|
|
2753
2168
|
@options[:error_title] = val.to_s
|
|
2754
2169
|
end
|
|
2755
2170
|
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
if val
|
|
2760
|
-
@options[:error] = val.to_s
|
|
2761
|
-
else
|
|
2762
|
-
@options[:error]
|
|
2763
|
-
end
|
|
2171
|
+
#: () -> String?
|
|
2172
|
+
def error_message
|
|
2173
|
+
@options[:error]
|
|
2764
2174
|
end
|
|
2765
2175
|
|
|
2766
2176
|
#: (String val) -> String
|
|
2767
2177
|
def error_message=(val)
|
|
2768
2178
|
@options[:error] = val.to_s
|
|
2769
2179
|
end
|
|
2770
|
-
# @deprecated Use {#error_message} instead. Will be removed in 0.2.0.
|
|
2771
|
-
alias error error_message
|
|
2772
|
-
# @deprecated Use {#error_message=} instead. Will be removed in 0.2.0.
|
|
2773
|
-
alias error= error_message=
|
|
2774
2180
|
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
if val
|
|
2779
|
-
@options[:prompt_title] = val.to_s
|
|
2780
|
-
else
|
|
2781
|
-
@options[:prompt_title]
|
|
2782
|
-
end
|
|
2181
|
+
#: () -> String?
|
|
2182
|
+
def prompt_title
|
|
2183
|
+
@options[:prompt_title]
|
|
2783
2184
|
end
|
|
2784
2185
|
|
|
2785
2186
|
#: (String val) -> String
|
|
@@ -2787,33 +2188,19 @@ module Xlsxrb
|
|
|
2787
2188
|
@options[:prompt_title] = val.to_s
|
|
2788
2189
|
end
|
|
2789
2190
|
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
if val
|
|
2794
|
-
@options[:prompt] = val.to_s
|
|
2795
|
-
else
|
|
2796
|
-
@options[:prompt]
|
|
2797
|
-
end
|
|
2191
|
+
#: () -> String?
|
|
2192
|
+
def prompt_message
|
|
2193
|
+
@options[:prompt]
|
|
2798
2194
|
end
|
|
2799
2195
|
|
|
2800
2196
|
#: (String val) -> String
|
|
2801
2197
|
def prompt_message=(val)
|
|
2802
2198
|
@options[:prompt] = val.to_s
|
|
2803
2199
|
end
|
|
2804
|
-
# @deprecated Use {#prompt_message} instead. Will be removed in 0.2.0.
|
|
2805
|
-
alias prompt prompt_message
|
|
2806
|
-
# @deprecated Use {#prompt_message=} instead. Will be removed in 0.2.0.
|
|
2807
|
-
alias prompt= prompt_message=
|
|
2808
2200
|
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
if val
|
|
2813
|
-
@options[:error_style] = val
|
|
2814
|
-
else
|
|
2815
|
-
@options[:error_style]
|
|
2816
|
-
end
|
|
2201
|
+
#: () -> untyped
|
|
2202
|
+
def error_style
|
|
2203
|
+
@options[:error_style]
|
|
2817
2204
|
end
|
|
2818
2205
|
|
|
2819
2206
|
#: (untyped val) -> untyped
|
|
@@ -2839,92 +2226,39 @@ module Xlsxrb
|
|
|
2839
2226
|
@options[:sqref] = sqref if sqref
|
|
2840
2227
|
end
|
|
2841
2228
|
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
# @api public
|
|
2846
|
-
#: (untyped key) -> untyped
|
|
2847
|
-
def [](key)
|
|
2848
|
-
warn "[Xlsxrb DEPRECATION] ConditionalFormatBuilder#[] is deprecated; use dedicated property accessors instead.", uplevel: 1
|
|
2849
|
-
@options[key.to_sym]
|
|
2850
|
-
end
|
|
2851
|
-
|
|
2852
|
-
# @deprecated Use dedicated property accessors instead. Will be removed in 0.2.0.
|
|
2853
|
-
# @param key [Symbol, String]
|
|
2854
|
-
# @param value [Object]
|
|
2855
|
-
# @return [Object]
|
|
2856
|
-
# @api public
|
|
2857
|
-
#: (untyped key, untyped value) -> untyped
|
|
2858
|
-
def []=(key, value)
|
|
2859
|
-
warn "[Xlsxrb DEPRECATION] ConditionalFormatBuilder#[]= is deprecated; use dedicated property accessors instead.", uplevel: 1
|
|
2860
|
-
@options[key.to_sym] = value
|
|
2861
|
-
end
|
|
2862
|
-
|
|
2863
|
-
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#sqref=} instead.
|
|
2864
|
-
#: (?String? val) -> String?
|
|
2865
|
-
def sqref(val = nil)
|
|
2866
|
-
if val
|
|
2867
|
-
@options[:sqref] = val.to_s
|
|
2868
|
-
else
|
|
2869
|
-
@options[:sqref]
|
|
2870
|
-
end
|
|
2229
|
+
#: () -> String?
|
|
2230
|
+
def sqref
|
|
2231
|
+
@options[:sqref]
|
|
2871
2232
|
end
|
|
2872
2233
|
|
|
2873
2234
|
#: (String val) -> String
|
|
2874
2235
|
def sqref=(val)
|
|
2875
2236
|
@options[:sqref] = val.to_s
|
|
2876
2237
|
end
|
|
2877
|
-
# @deprecated Use {#sqref} instead. Will be removed in 0.2.0.
|
|
2878
|
-
alias range sqref
|
|
2879
|
-
# @deprecated Use {#sqref=} instead. Will be removed in 0.2.0.
|
|
2880
|
-
alias range= sqref=
|
|
2881
2238
|
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
if val
|
|
2886
|
-
@options[:columns] = val
|
|
2887
|
-
else
|
|
2888
|
-
@options[:columns]
|
|
2889
|
-
end
|
|
2239
|
+
#: () -> untyped
|
|
2240
|
+
def columns
|
|
2241
|
+
@options[:columns]
|
|
2890
2242
|
end
|
|
2891
2243
|
|
|
2892
2244
|
#: (untyped val) -> untyped
|
|
2893
2245
|
def columns=(val)
|
|
2894
2246
|
@options[:columns] = val
|
|
2895
2247
|
end
|
|
2896
|
-
# @deprecated Use {#columns} instead. Will be removed in 0.2.0.
|
|
2897
|
-
alias col columns
|
|
2898
|
-
# @deprecated Use {#columns=} instead. Will be removed in 0.2.0.
|
|
2899
|
-
alias col= columns=
|
|
2900
2248
|
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
if val
|
|
2905
|
-
@options[:rows] = val
|
|
2906
|
-
else
|
|
2907
|
-
@options[:rows]
|
|
2908
|
-
end
|
|
2249
|
+
#: () -> untyped
|
|
2250
|
+
def rows
|
|
2251
|
+
@options[:rows]
|
|
2909
2252
|
end
|
|
2910
2253
|
|
|
2911
2254
|
#: (untyped val) -> untyped
|
|
2912
2255
|
def rows=(val)
|
|
2913
2256
|
@options[:rows] = val
|
|
2914
2257
|
end
|
|
2915
|
-
# @deprecated Use {#rows} instead. Will be removed in 0.2.0.
|
|
2916
|
-
alias row rows
|
|
2917
|
-
# @deprecated Use {#rows=} instead. Will be removed in 0.2.0.
|
|
2918
|
-
alias row= rows=
|
|
2919
2258
|
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
if val
|
|
2924
|
-
@options[:except_rows] = val
|
|
2925
|
-
else
|
|
2926
|
-
@options[:except_rows]
|
|
2927
|
-
end
|
|
2259
|
+
#: () -> untyped
|
|
2260
|
+
def except_rows
|
|
2261
|
+
@options[:except_rows]
|
|
2928
2262
|
end
|
|
2929
2263
|
|
|
2930
2264
|
#: (untyped val) -> untyped
|
|
@@ -2932,14 +2266,9 @@ module Xlsxrb
|
|
|
2932
2266
|
@options[:except_rows] = val
|
|
2933
2267
|
end
|
|
2934
2268
|
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
if val
|
|
2939
|
-
@options[:type] = val
|
|
2940
|
-
else
|
|
2941
|
-
@options[:type]
|
|
2942
|
-
end
|
|
2269
|
+
#: () -> untyped
|
|
2270
|
+
def type
|
|
2271
|
+
@options[:type]
|
|
2943
2272
|
end
|
|
2944
2273
|
|
|
2945
2274
|
#: (untyped val) -> untyped
|
|
@@ -2947,14 +2276,9 @@ module Xlsxrb
|
|
|
2947
2276
|
@options[:type] = val
|
|
2948
2277
|
end
|
|
2949
2278
|
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
if val
|
|
2954
|
-
@options[:operator] = val
|
|
2955
|
-
else
|
|
2956
|
-
@options[:operator]
|
|
2957
|
-
end
|
|
2279
|
+
#: () -> untyped
|
|
2280
|
+
def operator
|
|
2281
|
+
@options[:operator]
|
|
2958
2282
|
end
|
|
2959
2283
|
|
|
2960
2284
|
#: (untyped val) -> untyped
|
|
@@ -2962,14 +2286,9 @@ module Xlsxrb
|
|
|
2962
2286
|
@options[:operator] = val
|
|
2963
2287
|
end
|
|
2964
2288
|
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
if val
|
|
2969
|
-
@options[:formula] = val
|
|
2970
|
-
else
|
|
2971
|
-
@options[:formula]
|
|
2972
|
-
end
|
|
2289
|
+
#: () -> untyped
|
|
2290
|
+
def formula
|
|
2291
|
+
@options[:formula]
|
|
2973
2292
|
end
|
|
2974
2293
|
|
|
2975
2294
|
#: (untyped val) -> untyped
|
|
@@ -2977,39 +2296,9 @@ module Xlsxrb
|
|
|
2977
2296
|
@options[:formula] = val
|
|
2978
2297
|
end
|
|
2979
2298
|
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
#: (*untyped vals) -> untyped
|
|
2984
|
-
def formulas(*vals)
|
|
2985
|
-
warn "[Xlsxrb DEPRECATION] ConditionalFormatBuilder#formulas is deprecated; use #formula instead.", uplevel: 1
|
|
2986
|
-
if vals.empty?
|
|
2987
|
-
@options[:formulas]
|
|
2988
|
-
elsif vals.size == 1 && vals.first.is_a?(Array)
|
|
2989
|
-
@options[:formulas] = vals.first
|
|
2990
|
-
else
|
|
2991
|
-
@options[:formulas] = vals
|
|
2992
|
-
end
|
|
2993
|
-
end
|
|
2994
|
-
|
|
2995
|
-
# @deprecated Use {#formula=} instead. Will be removed in 0.2.0.
|
|
2996
|
-
# @param vals [Array, Object]
|
|
2997
|
-
# @return [Array]
|
|
2998
|
-
# @api public
|
|
2999
|
-
#: (untyped vals) -> untyped
|
|
3000
|
-
def formulas=(vals)
|
|
3001
|
-
warn "[Xlsxrb DEPRECATION] ConditionalFormatBuilder#formulas= is deprecated; use #formula= instead.", uplevel: 1
|
|
3002
|
-
@options[:formulas] = vals.is_a?(Array) ? vals : [vals]
|
|
3003
|
-
end
|
|
3004
|
-
|
|
3005
|
-
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#font=} instead.
|
|
3006
|
-
#: (?untyped val) -> untyped
|
|
3007
|
-
def font(val = nil)
|
|
3008
|
-
if val
|
|
3009
|
-
@options[:font] = val
|
|
3010
|
-
else
|
|
3011
|
-
@options[:font]
|
|
3012
|
-
end
|
|
2299
|
+
#: () -> untyped
|
|
2300
|
+
def font
|
|
2301
|
+
@options[:font]
|
|
3013
2302
|
end
|
|
3014
2303
|
|
|
3015
2304
|
#: (untyped val) -> untyped
|
|
@@ -3017,14 +2306,9 @@ module Xlsxrb
|
|
|
3017
2306
|
@options[:font] = val
|
|
3018
2307
|
end
|
|
3019
2308
|
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
if val
|
|
3024
|
-
@options[:fill] = val
|
|
3025
|
-
else
|
|
3026
|
-
@options[:fill]
|
|
3027
|
-
end
|
|
2309
|
+
#: () -> untyped
|
|
2310
|
+
def fill
|
|
2311
|
+
@options[:fill]
|
|
3028
2312
|
end
|
|
3029
2313
|
|
|
3030
2314
|
#: (untyped val) -> untyped
|
|
@@ -3032,14 +2316,9 @@ module Xlsxrb
|
|
|
3032
2316
|
@options[:fill] = val
|
|
3033
2317
|
end
|
|
3034
2318
|
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
if val
|
|
3039
|
-
@options[:fill_color] = val
|
|
3040
|
-
else
|
|
3041
|
-
@options[:fill_color]
|
|
3042
|
-
end
|
|
2319
|
+
#: () -> untyped
|
|
2320
|
+
def fill_color
|
|
2321
|
+
@options[:fill_color]
|
|
3043
2322
|
end
|
|
3044
2323
|
|
|
3045
2324
|
#: (untyped val) -> untyped
|
|
@@ -3047,14 +2326,9 @@ module Xlsxrb
|
|
|
3047
2326
|
@options[:fill_color] = val
|
|
3048
2327
|
end
|
|
3049
2328
|
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
if val
|
|
3054
|
-
@options[:font_color] = val
|
|
3055
|
-
else
|
|
3056
|
-
@options[:font_color]
|
|
3057
|
-
end
|
|
2329
|
+
#: () -> untyped
|
|
2330
|
+
def font_color
|
|
2331
|
+
@options[:font_color]
|
|
3058
2332
|
end
|
|
3059
2333
|
|
|
3060
2334
|
#: (untyped val) -> untyped
|
|
@@ -3062,14 +2336,9 @@ module Xlsxrb
|
|
|
3062
2336
|
@options[:font_color] = val
|
|
3063
2337
|
end
|
|
3064
2338
|
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
if val.nil?
|
|
3069
|
-
@options[:bold]
|
|
3070
|
-
else
|
|
3071
|
-
@options[:bold] = val ? true : false
|
|
3072
|
-
end
|
|
2339
|
+
#: () -> bool
|
|
2340
|
+
def bold?
|
|
2341
|
+
@options[:bold] ? true : false
|
|
3073
2342
|
end
|
|
3074
2343
|
|
|
3075
2344
|
#: (bool val) -> bool
|
|
@@ -3077,14 +2346,9 @@ module Xlsxrb
|
|
|
3077
2346
|
@options[:bold] = val ? true : false
|
|
3078
2347
|
end
|
|
3079
2348
|
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
if val.nil?
|
|
3084
|
-
@options[:italic]
|
|
3085
|
-
else
|
|
3086
|
-
@options[:italic] = val ? true : false
|
|
3087
|
-
end
|
|
2349
|
+
#: () -> bool
|
|
2350
|
+
def italic?
|
|
2351
|
+
@options[:italic] ? true : false
|
|
3088
2352
|
end
|
|
3089
2353
|
|
|
3090
2354
|
#: (bool val) -> bool
|
|
@@ -3092,14 +2356,9 @@ module Xlsxrb
|
|
|
3092
2356
|
@options[:italic] = val ? true : false
|
|
3093
2357
|
end
|
|
3094
2358
|
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
if val.nil?
|
|
3099
|
-
@options[:underline]
|
|
3100
|
-
else
|
|
3101
|
-
@options[:underline] = val
|
|
3102
|
-
end
|
|
2359
|
+
#: () -> untyped
|
|
2360
|
+
def underline
|
|
2361
|
+
@options[:underline]
|
|
3103
2362
|
end
|
|
3104
2363
|
|
|
3105
2364
|
#: (untyped val) -> untyped
|
|
@@ -3107,14 +2366,9 @@ module Xlsxrb
|
|
|
3107
2366
|
@options[:underline] = val
|
|
3108
2367
|
end
|
|
3109
2368
|
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
if val
|
|
3114
|
-
@options[:font_name] = val.to_s
|
|
3115
|
-
else
|
|
3116
|
-
@options[:font_name]
|
|
3117
|
-
end
|
|
2369
|
+
#: () -> String?
|
|
2370
|
+
def font_name
|
|
2371
|
+
@options[:font_name]
|
|
3118
2372
|
end
|
|
3119
2373
|
|
|
3120
2374
|
#: (String val) -> String
|
|
@@ -3122,55 +2376,19 @@ module Xlsxrb
|
|
|
3122
2376
|
@options[:font_name] = val.to_s
|
|
3123
2377
|
end
|
|
3124
2378
|
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
if val
|
|
3129
|
-
@options[:font_size] = val
|
|
3130
|
-
@options[:size] = val
|
|
3131
|
-
else
|
|
3132
|
-
@options[:font_size] || @options[:size]
|
|
3133
|
-
end
|
|
2379
|
+
#: () -> untyped
|
|
2380
|
+
def font_size
|
|
2381
|
+
@options[:font_size]
|
|
3134
2382
|
end
|
|
3135
2383
|
|
|
3136
2384
|
#: (untyped val) -> untyped
|
|
3137
2385
|
def font_size=(val)
|
|
3138
2386
|
@options[:font_size] = val
|
|
3139
|
-
@options[:size] = val
|
|
3140
|
-
end
|
|
3141
|
-
|
|
3142
|
-
# @deprecated Use {#font_size} instead. Will be removed in 0.2.0.
|
|
3143
|
-
def size(val = nil)
|
|
3144
|
-
warn "[DEPRECATION] `size` is deprecated; use `font_size` instead.", uplevel: 1
|
|
3145
|
-
font_size(val)
|
|
3146
|
-
end
|
|
3147
|
-
|
|
3148
|
-
# @deprecated Use {#font_size=} instead. Will be removed in 0.2.0.
|
|
3149
|
-
def size=(val)
|
|
3150
|
-
warn "[DEPRECATION] `size=` is deprecated; use `font_size=` instead.", uplevel: 1
|
|
3151
|
-
self.font_size = val
|
|
3152
|
-
end
|
|
3153
|
-
|
|
3154
|
-
# @deprecated Use {#font_size} instead. Will be removed in 0.2.0.
|
|
3155
|
-
def sz(val = nil)
|
|
3156
|
-
warn "[DEPRECATION] `sz` is deprecated; use `font_size` instead.", uplevel: 1
|
|
3157
|
-
font_size(val)
|
|
3158
|
-
end
|
|
3159
|
-
|
|
3160
|
-
# @deprecated Use {#font_size=} instead. Will be removed in 0.2.0.
|
|
3161
|
-
def sz=(val)
|
|
3162
|
-
warn "[DEPRECATION] `sz=` is deprecated; use `font_size=` instead.", uplevel: 1
|
|
3163
|
-
self.font_size = val
|
|
3164
2387
|
end
|
|
3165
2388
|
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
if val.nil?
|
|
3170
|
-
@options[:stop_if_true]
|
|
3171
|
-
else
|
|
3172
|
-
@options[:stop_if_true] = val ? true : false
|
|
3173
|
-
end
|
|
2389
|
+
#: () -> bool
|
|
2390
|
+
def stop_if_true?
|
|
2391
|
+
@options[:stop_if_true] ? true : false
|
|
3174
2392
|
end
|
|
3175
2393
|
|
|
3176
2394
|
#: (bool val) -> bool
|
|
@@ -3178,14 +2396,9 @@ module Xlsxrb
|
|
|
3178
2396
|
@options[:stop_if_true] = val ? true : false
|
|
3179
2397
|
end
|
|
3180
2398
|
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
if val
|
|
3185
|
-
@options[:priority] = val.to_i
|
|
3186
|
-
else
|
|
3187
|
-
@options[:priority]
|
|
3188
|
-
end
|
|
2399
|
+
#: () -> Integer?
|
|
2400
|
+
def priority
|
|
2401
|
+
@options[:priority]
|
|
3189
2402
|
end
|
|
3190
2403
|
|
|
3191
2404
|
#: (Integer val) -> Integer
|
|
@@ -3193,14 +2406,9 @@ module Xlsxrb
|
|
|
3193
2406
|
@options[:priority] = val.to_i
|
|
3194
2407
|
end
|
|
3195
2408
|
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
if val.nil?
|
|
3200
|
-
@options[:above_average]
|
|
3201
|
-
else
|
|
3202
|
-
@options[:above_average] = val ? true : false
|
|
3203
|
-
end
|
|
2409
|
+
#: () -> bool
|
|
2410
|
+
def above_average?
|
|
2411
|
+
@options[:above_average] ? true : false
|
|
3204
2412
|
end
|
|
3205
2413
|
|
|
3206
2414
|
#: (bool val) -> bool
|
|
@@ -3208,14 +2416,9 @@ module Xlsxrb
|
|
|
3208
2416
|
@options[:above_average] = val ? true : false
|
|
3209
2417
|
end
|
|
3210
2418
|
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
if val.nil?
|
|
3215
|
-
@options[:equal_average]
|
|
3216
|
-
else
|
|
3217
|
-
@options[:equal_average] = val ? true : false
|
|
3218
|
-
end
|
|
2419
|
+
#: () -> bool
|
|
2420
|
+
def equal_average?
|
|
2421
|
+
@options[:equal_average] ? true : false
|
|
3219
2422
|
end
|
|
3220
2423
|
|
|
3221
2424
|
#: (bool val) -> bool
|
|
@@ -3223,14 +2426,9 @@ module Xlsxrb
|
|
|
3223
2426
|
@options[:equal_average] = val ? true : false
|
|
3224
2427
|
end
|
|
3225
2428
|
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
if val
|
|
3230
|
-
@options[:std_dev] = val.to_i
|
|
3231
|
-
else
|
|
3232
|
-
@options[:std_dev]
|
|
3233
|
-
end
|
|
2429
|
+
#: () -> Integer?
|
|
2430
|
+
def std_dev
|
|
2431
|
+
@options[:std_dev]
|
|
3234
2432
|
end
|
|
3235
2433
|
|
|
3236
2434
|
#: (Integer val) -> Integer
|
|
@@ -3238,14 +2436,9 @@ module Xlsxrb
|
|
|
3238
2436
|
@options[:std_dev] = val.to_i
|
|
3239
2437
|
end
|
|
3240
2438
|
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
if val
|
|
3245
|
-
@options[:rank] = val.to_i
|
|
3246
|
-
else
|
|
3247
|
-
@options[:rank]
|
|
3248
|
-
end
|
|
2439
|
+
#: () -> Integer?
|
|
2440
|
+
def rank
|
|
2441
|
+
@options[:rank]
|
|
3249
2442
|
end
|
|
3250
2443
|
|
|
3251
2444
|
#: (Integer val) -> Integer
|
|
@@ -3253,14 +2446,9 @@ module Xlsxrb
|
|
|
3253
2446
|
@options[:rank] = val.to_i
|
|
3254
2447
|
end
|
|
3255
2448
|
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
if val.nil?
|
|
3260
|
-
@options[:percent]
|
|
3261
|
-
else
|
|
3262
|
-
@options[:percent] = val ? true : false
|
|
3263
|
-
end
|
|
2449
|
+
#: () -> bool
|
|
2450
|
+
def percent?
|
|
2451
|
+
@options[:percent] ? true : false
|
|
3264
2452
|
end
|
|
3265
2453
|
|
|
3266
2454
|
#: (bool val) -> bool
|
|
@@ -3268,14 +2456,9 @@ module Xlsxrb
|
|
|
3268
2456
|
@options[:percent] = val ? true : false
|
|
3269
2457
|
end
|
|
3270
2458
|
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
if val.nil?
|
|
3275
|
-
@options[:bottom]
|
|
3276
|
-
else
|
|
3277
|
-
@options[:bottom] = val ? true : false
|
|
3278
|
-
end
|
|
2459
|
+
#: () -> bool
|
|
2460
|
+
def bottom?
|
|
2461
|
+
@options[:bottom] ? true : false
|
|
3279
2462
|
end
|
|
3280
2463
|
|
|
3281
2464
|
#: (bool val) -> bool
|
|
@@ -3283,14 +2466,9 @@ module Xlsxrb
|
|
|
3283
2466
|
@options[:bottom] = val ? true : false
|
|
3284
2467
|
end
|
|
3285
2468
|
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
if val
|
|
3290
|
-
@options[:text] = val.to_s
|
|
3291
|
-
else
|
|
3292
|
-
@options[:text]
|
|
3293
|
-
end
|
|
2469
|
+
#: () -> String?
|
|
2470
|
+
def text
|
|
2471
|
+
@options[:text]
|
|
3294
2472
|
end
|
|
3295
2473
|
|
|
3296
2474
|
#: (String val) -> String
|
|
@@ -3298,14 +2476,9 @@ module Xlsxrb
|
|
|
3298
2476
|
@options[:text] = val.to_s
|
|
3299
2477
|
end
|
|
3300
2478
|
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
if val
|
|
3305
|
-
@options[:time_period] = val
|
|
3306
|
-
else
|
|
3307
|
-
@options[:time_period]
|
|
3308
|
-
end
|
|
2479
|
+
#: () -> untyped
|
|
2480
|
+
def time_period
|
|
2481
|
+
@options[:time_period]
|
|
3309
2482
|
end
|
|
3310
2483
|
|
|
3311
2484
|
#: (untyped val) -> untyped
|
|
@@ -3313,14 +2486,9 @@ module Xlsxrb
|
|
|
3313
2486
|
@options[:time_period] = val
|
|
3314
2487
|
end
|
|
3315
2488
|
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
if val
|
|
3320
|
-
@options[:color_scale] = val
|
|
3321
|
-
else
|
|
3322
|
-
@options[:color_scale]
|
|
3323
|
-
end
|
|
2489
|
+
#: () -> untyped
|
|
2490
|
+
def color_scale
|
|
2491
|
+
@options[:color_scale]
|
|
3324
2492
|
end
|
|
3325
2493
|
|
|
3326
2494
|
#: (untyped val) -> untyped
|
|
@@ -3328,14 +2496,9 @@ module Xlsxrb
|
|
|
3328
2496
|
@options[:color_scale] = val
|
|
3329
2497
|
end
|
|
3330
2498
|
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
if val
|
|
3335
|
-
@options[:data_bar] = val
|
|
3336
|
-
else
|
|
3337
|
-
@options[:data_bar]
|
|
3338
|
-
end
|
|
2499
|
+
#: () -> untyped
|
|
2500
|
+
def data_bar
|
|
2501
|
+
@options[:data_bar]
|
|
3339
2502
|
end
|
|
3340
2503
|
|
|
3341
2504
|
#: (untyped val) -> untyped
|
|
@@ -3343,14 +2506,9 @@ module Xlsxrb
|
|
|
3343
2506
|
@options[:data_bar] = val
|
|
3344
2507
|
end
|
|
3345
2508
|
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
if val
|
|
3350
|
-
@options[:icon_set] = val
|
|
3351
|
-
else
|
|
3352
|
-
@options[:icon_set]
|
|
3353
|
-
end
|
|
2509
|
+
#: () -> untyped
|
|
2510
|
+
def icon_set
|
|
2511
|
+
@options[:icon_set]
|
|
3354
2512
|
end
|
|
3355
2513
|
|
|
3356
2514
|
#: (untyped val) -> untyped
|
|
@@ -3358,14 +2516,9 @@ module Xlsxrb
|
|
|
3358
2516
|
@options[:icon_set] = val
|
|
3359
2517
|
end
|
|
3360
2518
|
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
if val
|
|
3365
|
-
@options[:dxf] = val
|
|
3366
|
-
else
|
|
3367
|
-
@options[:dxf]
|
|
3368
|
-
end
|
|
2519
|
+
#: () -> untyped
|
|
2520
|
+
def dxf
|
|
2521
|
+
@options[:dxf]
|
|
3369
2522
|
end
|
|
3370
2523
|
|
|
3371
2524
|
#: (untyped val) -> untyped
|
|
@@ -3373,19 +2526,13 @@ module Xlsxrb
|
|
|
3373
2526
|
@options[:dxf] = val
|
|
3374
2527
|
end
|
|
3375
2528
|
|
|
3376
|
-
# Gets
|
|
2529
|
+
# Gets the differential format identifier (dxfId).
|
|
3377
2530
|
#
|
|
3378
|
-
# @param val [Integer, nil]
|
|
3379
2531
|
# @return [Integer, nil]
|
|
3380
2532
|
# @api public
|
|
3381
|
-
#: (
|
|
3382
|
-
def dxf_id
|
|
3383
|
-
|
|
3384
|
-
@options[:dxf_id] = val.to_i
|
|
3385
|
-
@options[:format_id] = val.to_i
|
|
3386
|
-
else
|
|
3387
|
-
@options[:dxf_id] || @options[:format_id]
|
|
3388
|
-
end
|
|
2533
|
+
#: () -> Integer?
|
|
2534
|
+
def dxf_id
|
|
2535
|
+
@options[:dxf_id]
|
|
3389
2536
|
end
|
|
3390
2537
|
|
|
3391
2538
|
# Sets the differential format identifier (dxfId).
|
|
@@ -3396,21 +2543,6 @@ module Xlsxrb
|
|
|
3396
2543
|
#: (Integer val) -> Integer
|
|
3397
2544
|
def dxf_id=(val)
|
|
3398
2545
|
@options[:dxf_id] = val.to_i
|
|
3399
|
-
@options[:format_id] = val.to_i
|
|
3400
|
-
end
|
|
3401
|
-
|
|
3402
|
-
# @deprecated Use {#dxf_id} instead. Will be removed in 0.2.0.
|
|
3403
|
-
#: (?Integer? val) -> Integer?
|
|
3404
|
-
def format_id(val = nil)
|
|
3405
|
-
warn "[DEPRECATION] `format_id` is deprecated; use `dxf_id` instead.", uplevel: 1
|
|
3406
|
-
dxf_id(val)
|
|
3407
|
-
end
|
|
3408
|
-
|
|
3409
|
-
# @deprecated Use {#dxf_id=} instead. Will be removed in 0.2.0.
|
|
3410
|
-
#: (Integer val) -> Integer
|
|
3411
|
-
def format_id=(val)
|
|
3412
|
-
warn "[DEPRECATION] `format_id=` is deprecated; use `dxf_id=` instead.", uplevel: 1
|
|
3413
|
-
self.dxf_id = val
|
|
3414
2546
|
end
|
|
3415
2547
|
|
|
3416
2548
|
#: () -> Hash[Symbol, untyped]
|