xlsxrb 0.1.17 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +256 -1
- data/README.md +111 -28
- data/lib/ruby_lsp/xlsxrb/completion_listener.rb +439 -139
- data/lib/xlsxrb/chart_builder.rb +540 -193
- data/lib/xlsxrb/dsl_helpers.rb +178 -73
- data/lib/xlsxrb/elements/cell.rb +197 -130
- data/lib/xlsxrb/elements/column.rb +88 -7
- data/lib/xlsxrb/elements/coordinate_access.rb +86 -59
- data/lib/xlsxrb/elements/image.rb +18 -19
- data/lib/xlsxrb/elements/metadata.rb +2379 -0
- data/lib/xlsxrb/elements/row.rb +84 -118
- data/lib/xlsxrb/elements/styles.rb +140 -90
- data/lib/xlsxrb/elements/types.rb +164 -22
- data/lib/xlsxrb/elements/workbook.rb +122 -140
- data/lib/xlsxrb/elements/worksheet.rb +451 -226
- data/lib/xlsxrb/elements.rb +1 -0
- data/lib/xlsxrb/ooxml/reader/listeners/core_listeners.rb +16 -5
- data/lib/xlsxrb/ooxml/reader/listeners/drawing_listeners.rb +14 -9
- data/lib/xlsxrb/ooxml/reader/listeners/feature_listeners.rb +296 -34
- data/lib/xlsxrb/ooxml/reader/listeners/style_listeners.rb +17 -3
- data/lib/xlsxrb/ooxml/reader.rb +52 -50
- data/lib/xlsxrb/ooxml/styles_parser.rb +36 -5
- data/lib/xlsxrb/ooxml/utils.rb +2 -2
- data/lib/xlsxrb/ooxml/workbook_parser.rb +0 -1
- data/lib/xlsxrb/ooxml/workbook_writer.rb +242 -109
- data/lib/xlsxrb/ooxml/worksheet_parser.rb +63 -31
- data/lib/xlsxrb/ooxml/worksheet_writer.rb +119 -56
- data/lib/xlsxrb/ooxml/writer/drawing_xml.rb +33 -13
- data/lib/xlsxrb/ooxml/writer/features_xml.rb +75 -15
- data/lib/xlsxrb/ooxml/writer/styles_xml.rb +18 -8
- data/lib/xlsxrb/ooxml/writer.rb +124 -44
- data/lib/xlsxrb/ooxml/xml_parser.rb +78 -5
- data/lib/xlsxrb/ooxml/zip_generator.rb +2 -0
- data/lib/xlsxrb/ooxml/zip_reader.rb +112 -25
- data/lib/xlsxrb/ooxml/zip_writer.rb +119 -30
- data/lib/xlsxrb/stream_row.rb +56 -81
- data/lib/xlsxrb/stream_sheet.rb +542 -273
- data/lib/xlsxrb/stream_writer.rb +1536 -870
- data/lib/xlsxrb/style_builder.rb +667 -221
- data/lib/xlsxrb/version.rb +1 -1
- data/lib/xlsxrb/workbook_builder.rb +406 -143
- data/lib/xlsxrb/worksheet_builder.rb +1009 -900
- data/lib/xlsxrb.rb +1179 -1056
- data/sig/generated/xlsxrb/chart_builder.rbs +385 -159
- data/sig/generated/xlsxrb/dsl_helpers.rbs +81 -15
- data/sig/generated/xlsxrb/elements/cell.rbs +78 -70
- data/sig/generated/xlsxrb/elements/column.rbs +55 -3
- data/sig/generated/xlsxrb/elements/coordinate_access.rbs +35 -29
- data/sig/generated/xlsxrb/elements/image.rbs +7 -11
- data/sig/generated/xlsxrb/elements/metadata.rbs +1574 -0
- data/sig/generated/xlsxrb/elements/row.rbs +39 -42
- data/sig/generated/xlsxrb/elements/styles.rbs +66 -66
- data/sig/generated/xlsxrb/elements/types.rbs +27 -0
- data/sig/generated/xlsxrb/elements/workbook.rbs +46 -99
- data/sig/generated/xlsxrb/elements/worksheet.rbs +121 -96
- data/sig/generated/xlsxrb/ooxml/reader/listeners/feature_listeners.rbs +61 -4
- data/sig/generated/xlsxrb/ooxml/reader.rbs +2 -2
- 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 +13 -1
- data/sig/generated/xlsxrb/ooxml/worksheet_parser.rbs +16 -0
- data/sig/generated/xlsxrb/ooxml/worksheet_writer.rbs +6 -4
- data/sig/generated/xlsxrb/ooxml/writer/features_xml.rbs +7 -0
- data/sig/generated/xlsxrb/ooxml/writer.rbs +22 -13
- data/sig/generated/xlsxrb/ooxml/xml_parser.rbs +70 -0
- data/sig/generated/xlsxrb/ooxml/zip_generator.rbs +2 -0
- data/sig/generated/xlsxrb/ooxml/zip_reader.rbs +24 -9
- data/sig/generated/xlsxrb/ooxml/zip_writer.rbs +26 -1
- data/sig/generated/xlsxrb/stream_row.rbs +32 -33
- data/sig/generated/xlsxrb/stream_sheet.rbs +233 -181
- data/sig/generated/xlsxrb/stream_writer.rbs +961 -667
- data/sig/generated/xlsxrb/style_builder.rbs +402 -128
- data/sig/generated/xlsxrb/workbook_builder.rbs +223 -71
- data/sig/generated/xlsxrb/worksheet_builder.rbs +579 -453
- data/sig/generated/xlsxrb.rbs +205 -144
- data/sig/rexml.rbs +8 -0
- metadata +5 -5
- data/lib/xlsxrb/utils.rb +0 -291
- data/sig/generated/xlsxrb/utils.rbs +0 -184
|
@@ -17,23 +17,132 @@ module Xlsxrb
|
|
|
17
17
|
class Worksheet
|
|
18
18
|
[Enumerable, CoordinateAccess].each { |m| include m }
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
# @return [Array<Hash[Symbol, untyped]>]
|
|
21
|
+
#
|
|
22
|
+
# Corresponds to ECMA-376 Part 4 §18.3.1.18 (<conditionalFormatting> and <cfRule> elements).
|
|
23
|
+
# In the OpenXML specification, conditional formatting definitions are emitted as
|
|
24
|
+
# `<conditionalFormatting>` elements containing individual rule definitions (`<cfRule>`).
|
|
25
|
+
# While ECMA-376 uses the uncountable noun `conditionalFormatting` as the XML element name,
|
|
26
|
+
# xlsxrb exposes these rules collectively as {#conditional_formats} (Array of Hashes)
|
|
27
|
+
# to maintain symmetric plural collection naming alongside other collections
|
|
28
|
+
# (e.g. {#tables}, {#data_validations}, {#merged_cells}) and paired with the singular builder
|
|
29
|
+
# method {WorksheetBuilder#conditional_format}.
|
|
30
|
+
#
|
|
31
|
+
# @api public
|
|
32
|
+
#: Array[Elements::ConditionalFormat]
|
|
33
|
+
attr_reader :conditional_formats
|
|
34
|
+
|
|
35
|
+
#: String?
|
|
36
|
+
attr_reader :name
|
|
37
|
+
#: Array[Elements::Row]
|
|
38
|
+
attr_reader :rows
|
|
39
|
+
#: Array[Elements::Column]
|
|
40
|
+
attr_reader :columns
|
|
41
|
+
#: Array[Elements::Chart]
|
|
42
|
+
attr_reader :charts
|
|
43
|
+
#: Array[Elements::DataValidation]
|
|
44
|
+
attr_reader :data_validations
|
|
45
|
+
#: Hash[untyped, untyped]
|
|
46
|
+
attr_reader :unmapped_data
|
|
47
|
+
#: Array[String]
|
|
48
|
+
attr_reader :errors
|
|
49
|
+
#: Symbol
|
|
50
|
+
attr_reader :state
|
|
51
|
+
#: Hash[String, Elements::Hyperlink]
|
|
52
|
+
attr_reader :hyperlinks
|
|
53
|
+
#: Array[Elements::Comment]
|
|
54
|
+
attr_reader :comments
|
|
55
|
+
#: Array[Elements::Image]
|
|
56
|
+
attr_reader :images
|
|
57
|
+
#: (Elements::Styles | Hash[untyped, untyped])?
|
|
58
|
+
attr_reader :styles
|
|
59
|
+
#: String?
|
|
60
|
+
attr_reader :print_area
|
|
61
|
+
#: Elements::PrintTitles?
|
|
62
|
+
attr_reader :print_titles
|
|
63
|
+
#: Array[Elements::SparklineGroup]
|
|
64
|
+
attr_reader :sparkline_groups
|
|
65
|
+
#: Array[String]
|
|
66
|
+
attr_reader :merged_cells
|
|
67
|
+
#: String?
|
|
68
|
+
attr_reader :auto_filter
|
|
69
|
+
#: Array[Elements::Table]
|
|
70
|
+
attr_reader :tables
|
|
71
|
+
#: Array[Elements::Shape]
|
|
72
|
+
attr_reader :shapes
|
|
73
|
+
#: Elements::FreezePane?
|
|
74
|
+
attr_reader :freeze_pane
|
|
75
|
+
#: Elements::PageSetup
|
|
76
|
+
attr_reader :page_setup
|
|
77
|
+
#: Elements::PageMargins?
|
|
78
|
+
attr_reader :page_margins
|
|
79
|
+
#: Elements::HeaderFooter
|
|
80
|
+
attr_reader :header_footer
|
|
81
|
+
#: Elements::PrintOptions
|
|
82
|
+
attr_reader :print_options
|
|
83
|
+
#: Elements::SheetProtection?
|
|
84
|
+
attr_reader :sheet_protection
|
|
85
|
+
#: Elements::SheetView
|
|
86
|
+
attr_reader :sheet_view
|
|
87
|
+
#: Elements::SheetProperties
|
|
88
|
+
attr_reader :sheet_properties
|
|
89
|
+
#: Elements::SheetFormat
|
|
90
|
+
attr_reader :sheet_format
|
|
91
|
+
#: Array[Elements::PageBreak]
|
|
92
|
+
attr_reader :row_breaks
|
|
93
|
+
#: Array[Elements::PageBreak]
|
|
94
|
+
attr_reader :column_breaks
|
|
95
|
+
#: Array[Elements::ProtectedRange]
|
|
96
|
+
attr_reader :protected_ranges
|
|
97
|
+
#: Array[String]
|
|
98
|
+
attr_reader :cell_watches
|
|
99
|
+
#: Array[Elements::IgnoredError]
|
|
100
|
+
attr_reader :ignored_errors
|
|
101
|
+
#: Elements::PhoneticProperties?
|
|
102
|
+
attr_reader :phonetic_properties
|
|
103
|
+
#: (Elements::Selection | Array[Elements::Selection])?
|
|
104
|
+
attr_reader :selection
|
|
105
|
+
#: Elements::BackgroundImage?
|
|
106
|
+
attr_reader :background_image
|
|
107
|
+
#: Array[Elements::ThreadedComment]
|
|
108
|
+
attr_reader :threaded_comments
|
|
109
|
+
#: Array[Elements::PivotTable]
|
|
110
|
+
attr_reader :pivot_tables
|
|
111
|
+
#: Elements::SplitPane?
|
|
112
|
+
attr_reader :split_pane
|
|
113
|
+
#: Hash[Integer, Elements::FilterColumn]
|
|
114
|
+
attr_reader :filter_columns
|
|
115
|
+
#: Elements::SortState?
|
|
116
|
+
attr_reader :sort_state
|
|
117
|
+
#: Array[Elements::HeaderFooterImage]
|
|
118
|
+
attr_reader :header_footer_images
|
|
119
|
+
|
|
120
|
+
# Support array pattern matching.
|
|
121
|
+
#
|
|
122
|
+
# @return [Array<Object>]
|
|
123
|
+
# @api public
|
|
124
|
+
#: () -> Array[untyped]
|
|
125
|
+
def deconstruct
|
|
126
|
+
[name, rows, columns]
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# Returns worksheet calculation properties (<sheetCalcPr>), or nil if none configured.
|
|
130
|
+
#
|
|
131
|
+
# @return [Elements::SheetCalcProperties, nil]
|
|
132
|
+
# @api public
|
|
133
|
+
#: () -> Elements::SheetCalcProperties?
|
|
134
|
+
def sheet_calc_properties
|
|
135
|
+
@sheet_calc_pr
|
|
136
|
+
end
|
|
27
137
|
|
|
28
138
|
# @param name [String] The worksheet name (max 31 characters).
|
|
29
139
|
# @param rows [Array<Elements::Row>] Rows in the sheet.
|
|
30
140
|
# @param columns [Array<Elements::Column>] Column definitions.
|
|
31
141
|
# @param charts [Array<Hash>] Charts in the sheet.
|
|
32
|
-
# @param
|
|
142
|
+
# @param conditional_formats [Array<Hash, Elements::ConditionalFormat>] Conditional formatting rules.
|
|
33
143
|
# @param data_validations [Array<Hash>] Data validation rules.
|
|
34
144
|
# @param unmapped_data [Hash] Additional metadata for round-tripping.
|
|
35
145
|
# @param errors [Array<String>, nil] Validation errors.
|
|
36
|
-
# @param conditional_formats [Array<Hash>, nil] Alias for conditional_formatting.
|
|
37
146
|
# @param state [Symbol] Sheet visibility state (:visible, :hidden, or :very_hidden).
|
|
38
147
|
# @param hyperlinks [Hash{String => Hash}] Hyperlink mappings by cell reference.
|
|
39
148
|
# @param comments [Array<Hash>] Comments and notes in the sheet.
|
|
@@ -60,63 +169,234 @@ module Xlsxrb
|
|
|
60
169
|
# @param sheet_properties [Hash] Sheet properties (e.g. tabColor, outlinePr).
|
|
61
170
|
# @param sheet_format [Hash] Sheet format properties (e.g. defaultRowHeight, defaultColWidth).
|
|
62
171
|
# @param row_breaks [Array<Integer | Hash>] Explicit page row breaks.
|
|
63
|
-
# @param
|
|
172
|
+
# @param column_breaks [Array<Integer | Hash>] Explicit page column breaks.
|
|
64
173
|
# @param protected_ranges [Array<Hash>] Protected range definitions.
|
|
65
174
|
# @param cell_watches [Array<String>] Watched cell references.
|
|
66
175
|
# @param ignored_errors [Array<Hash>] Ignored error rules.
|
|
67
176
|
# @param phonetic_properties [Hash, nil] Phonetic text properties.
|
|
68
177
|
# @param selection [Hash, Array<Hash>, nil] Active cell and selection settings.
|
|
69
|
-
# @param
|
|
178
|
+
# @param sheet_calc_properties [Hash, nil] Worksheet calculation properties.
|
|
70
179
|
# @param background_image [Hash, nil] Worksheet background image specification.
|
|
71
180
|
# @param threaded_comments [Array<Hash>] Threaded comments in the sheet.
|
|
72
|
-
#: (name: String?, ?rows: Array[Elements::Row], ?columns: Array[Elements::Column], ?charts: Array[
|
|
73
|
-
def initialize(name:, rows: [], columns: [], charts: [],
|
|
181
|
+
#: (name: String?, ?rows: Array[Elements::Row], ?columns: Array[Elements::Column], ?charts: Array[untyped], ?data_validations: Array[untyped], ?unmapped_data: Hash[untyped, untyped], ?errors: Array[String]?, ?conditional_formats: Array[untyped]?, ?state: Symbol, ?hyperlinks: Hash[String, untyped], ?comments: Array[untyped], ?images: Array[Elements::Image], ?styles: (Elements::Styles | Hash[untyped, untyped])?, ?date1904: bool, ?dimension: String?, ?trim_empty_rows: bool, ?pad_empty_rows: bool, ?pad_empty_cells: bool, ?print_area: String?, ?print_titles: untyped, ?sparkline_groups: Array[untyped], ?merged_cells: Array[String], ?auto_filter: String?, ?tables: Array[untyped], ?shapes: Array[untyped], ?freeze_pane: untyped, ?page_setup: untyped, ?page_margins: untyped, ?header_footer: untyped, ?print_options: untyped, ?sheet_protection: untyped, ?sheet_view: untyped, ?sheet_properties: untyped, ?sheet_format: untyped, ?row_breaks: Array[untyped], ?column_breaks: Array[untyped]?, ?protected_ranges: Array[untyped], ?cell_watches: Array[String], ?ignored_errors: Array[untyped], ?phonetic_properties: untyped, ?selection: untyped, ?sheet_calc_properties: untyped, ?background_image: untyped, ?threaded_comments: Array[untyped], ?pivot_tables: Array[untyped]?, ?split_pane: untyped, ?filter_columns: Hash[Integer, untyped]?, ?sort_state: untyped, ?header_footer_images: Array[untyped]?) -> void
|
|
182
|
+
def initialize(name:, rows: [], columns: [], charts: [], data_validations: [], unmapped_data: {}, errors: nil, conditional_formats: nil, state: :visible, hyperlinks: {}, comments: [], images: [], styles: nil, date1904: false, dimension: nil, trim_empty_rows: false, pad_empty_rows: false, pad_empty_cells: false, print_area: nil, print_titles: nil, sparkline_groups: [], merged_cells: [], auto_filter: nil, tables: [], shapes: [], freeze_pane: nil, page_setup: {}, page_margins: nil, header_footer: {}, print_options: {}, sheet_protection: nil, sheet_view: {}, sheet_properties: {}, sheet_format: {}, row_breaks: [], column_breaks: nil, protected_ranges: [], cell_watches: [], ignored_errors: [], phonetic_properties: nil, selection: nil, sheet_calc_properties: nil, background_image: nil, threaded_comments: [], pivot_tables: nil, split_pane: nil, filter_columns: nil, sort_state: nil, header_footer_images: nil)
|
|
74
183
|
@name = name
|
|
75
184
|
@rows = (rows || []).freeze
|
|
76
185
|
@columns = (columns || []).freeze
|
|
77
|
-
@charts = (charts || []).freeze
|
|
78
|
-
cf =
|
|
79
|
-
|
|
80
|
-
|
|
186
|
+
@charts = (charts || []).map { |c| c.is_a?(Elements::Chart) ? c : Elements::Chart.new(**c) }.freeze
|
|
187
|
+
cf = (conditional_formats || []).map do |c|
|
|
188
|
+
if c.is_a?(Hash)
|
|
189
|
+
Elements::ConditionalFormat.new(**c)
|
|
190
|
+
else
|
|
191
|
+
c
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
@conditional_formats = cf.freeze
|
|
195
|
+
@data_validations = (data_validations || []).map { |dv| dv.is_a?(Elements::DataValidation) ? dv : Elements::DataValidation.new(**dv) }.freeze
|
|
81
196
|
@unmapped_data = (unmapped_data || {}).freeze
|
|
82
197
|
computed_errors = errors || self.class.validate(@name, @rows)
|
|
83
198
|
@errors = computed_errors.freeze
|
|
84
199
|
@state = state ? state.to_sym : :visible
|
|
85
|
-
@hyperlinks = (hyperlinks || {}).
|
|
86
|
-
|
|
200
|
+
@hyperlinks = (hyperlinks || {}).to_h do |ref, hl|
|
|
201
|
+
hl_obj = case hl
|
|
202
|
+
when Hash
|
|
203
|
+
Elements::Hyperlink.new(**hl)
|
|
204
|
+
when String
|
|
205
|
+
Elements::Hyperlink.new(url: hl)
|
|
206
|
+
else
|
|
207
|
+
hl
|
|
208
|
+
end
|
|
209
|
+
[ref.to_s, hl_obj]
|
|
210
|
+
end.freeze
|
|
211
|
+
@comments = (comments || []).map { |c| c.is_a?(Elements::Comment) ? c : Elements::Comment.new(**c) }.freeze
|
|
87
212
|
@images = (images || []).freeze
|
|
88
213
|
@styles = styles
|
|
89
214
|
@date1904 = date1904 ? true : false
|
|
90
215
|
@dimension = dimension
|
|
91
216
|
@print_area = print_area
|
|
92
|
-
@print_titles = print_titles
|
|
93
|
-
|
|
217
|
+
@print_titles = if print_titles.nil?
|
|
218
|
+
nil
|
|
219
|
+
elsif print_titles.is_a?(Elements::PrintTitles)
|
|
220
|
+
print_titles
|
|
221
|
+
else
|
|
222
|
+
pt_cols = print_titles[:columns] || print_titles[:cols]
|
|
223
|
+
Elements::PrintTitles.new(rows: print_titles[:rows], columns: pt_cols)
|
|
224
|
+
end
|
|
225
|
+
@sparkline_groups = (sparkline_groups || []).map do |sg|
|
|
226
|
+
if sg.is_a?(Hash)
|
|
227
|
+
sls = (sg[:sparklines] || []).map do |s|
|
|
228
|
+
if s.is_a?(Hash)
|
|
229
|
+
sqref = s[:sqref] || s[:location_ref] || s[:location]
|
|
230
|
+
formula = s[:formula] || s[:data_ref] || s[:f] || s[:data]
|
|
231
|
+
Elements::Sparkline.new(sqref: sqref&.to_s, formula: formula&.to_s)
|
|
232
|
+
elsif s.is_a?(Elements::Sparkline)
|
|
233
|
+
s
|
|
234
|
+
else
|
|
235
|
+
Elements::Sparkline.new(sqref: s.to_s)
|
|
236
|
+
end
|
|
237
|
+
end
|
|
238
|
+
Elements::SparklineGroup.new(**sg, sparklines: sls)
|
|
239
|
+
else
|
|
240
|
+
sg
|
|
241
|
+
end
|
|
242
|
+
end.freeze
|
|
94
243
|
@trim_empty_rows = trim_empty_rows ? true : false
|
|
95
244
|
@pad_empty_rows = pad_empty_rows ? true : false
|
|
96
245
|
@pad_empty_cells = pad_empty_cells ? true : false
|
|
97
|
-
@threaded_comments = (threaded_comments || []).freeze
|
|
246
|
+
@threaded_comments = (threaded_comments || []).map { |tc| tc.is_a?(Elements::ThreadedComment) ? tc : Elements::ThreadedComment.new(**tc) }.freeze
|
|
98
247
|
@merged_cells = (merged_cells || []).freeze
|
|
99
248
|
@auto_filter = auto_filter
|
|
100
|
-
@tables = (tables || []).
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
249
|
+
@tables = (tables || []).map do |tb|
|
|
250
|
+
if tb.is_a?(Hash)
|
|
251
|
+
cols = (tb[:columns] || []).each_with_index.map do |col, idx|
|
|
252
|
+
if col.is_a?(Hash)
|
|
253
|
+
Elements::TableColumn.new(**col)
|
|
254
|
+
elsif col.is_a?(Elements::TableColumn)
|
|
255
|
+
col
|
|
256
|
+
else
|
|
257
|
+
Elements::TableColumn.new(name: col.to_s, id: idx + 1)
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
si = tb[:style_info] || Elements::Table.style_info_from(tb)
|
|
261
|
+
si = Elements::TableStyleInfo.new(**si) if si.is_a?(Hash)
|
|
262
|
+
Elements::Table.new(**tb, columns: cols, style_info: si)
|
|
263
|
+
else
|
|
264
|
+
tb
|
|
265
|
+
end
|
|
266
|
+
end.freeze
|
|
267
|
+
@shapes = (shapes || []).map { |s| s.is_a?(Elements::Shape) ? s : Elements::Shape.new(**s) }.freeze
|
|
268
|
+
@freeze_pane = if freeze_pane.nil?
|
|
269
|
+
nil
|
|
270
|
+
elsif freeze_pane.is_a?(Elements::FreezePane)
|
|
271
|
+
freeze_pane
|
|
272
|
+
else
|
|
273
|
+
Elements::FreezePane.new(**freeze_pane)
|
|
274
|
+
end
|
|
275
|
+
ps = page_setup || {}
|
|
276
|
+
@page_setup = ps.is_a?(Elements::PageSetup) ? ps : Elements::PageSetup.new(**ps)
|
|
277
|
+
@page_margins = if page_margins.nil?
|
|
278
|
+
nil
|
|
279
|
+
elsif page_margins.is_a?(Elements::PageMargins)
|
|
280
|
+
page_margins
|
|
281
|
+
else
|
|
282
|
+
Elements::PageMargins.new(**page_margins)
|
|
283
|
+
end
|
|
284
|
+
hf = header_footer || {}
|
|
285
|
+
@header_footer = hf.is_a?(Elements::HeaderFooter) ? hf : Elements::HeaderFooter.new(**hf)
|
|
286
|
+
po = print_options || {}
|
|
287
|
+
@print_options = po.is_a?(Elements::PrintOptions) ? po : Elements::PrintOptions.new(**po)
|
|
288
|
+
@sheet_protection = if sheet_protection.nil?
|
|
289
|
+
nil
|
|
290
|
+
elsif sheet_protection.is_a?(Elements::SheetProtection)
|
|
291
|
+
sheet_protection
|
|
292
|
+
else
|
|
293
|
+
Elements::SheetProtection.new(**sheet_protection)
|
|
294
|
+
end
|
|
295
|
+
sv = sheet_view || {}
|
|
296
|
+
@sheet_view = sv.is_a?(Elements::SheetView) ? sv : Elements::SheetView.new(**sv)
|
|
297
|
+
sp = sheet_properties || {}
|
|
298
|
+
@sheet_properties = sp.is_a?(Elements::SheetProperties) ? sp : Elements::SheetProperties.new(**sp)
|
|
299
|
+
sf = sheet_format || unmapped_data[:sheet_format] || unmapped_data.dig(:facade, :sheet_format) || {}
|
|
300
|
+
@sheet_format = sf.is_a?(Elements::SheetFormat) ? sf : Elements::SheetFormat.new(**sf)
|
|
301
|
+
@row_breaks = (row_breaks || []).map do |brk|
|
|
302
|
+
if brk.is_a?(Elements::PageBreak)
|
|
303
|
+
brk
|
|
304
|
+
elsif brk.is_a?(Hash)
|
|
305
|
+
Elements::PageBreak.new(**brk)
|
|
306
|
+
else
|
|
307
|
+
Elements::PageBreak.new(id: brk.to_i, max: 16_383, man: 1)
|
|
308
|
+
end
|
|
309
|
+
end.freeze
|
|
310
|
+
raw_col_breaks = column_breaks || []
|
|
311
|
+
breaks = raw_col_breaks.map do |brk|
|
|
312
|
+
if brk.is_a?(Elements::PageBreak)
|
|
313
|
+
brk
|
|
314
|
+
elsif brk.is_a?(Hash)
|
|
315
|
+
Elements::PageBreak.new(**brk)
|
|
316
|
+
else
|
|
317
|
+
col_id = Elements::Cell._column_index(brk)
|
|
318
|
+
Elements::PageBreak.new(id: col_id, max: 1_048_575, man: 1)
|
|
319
|
+
end
|
|
320
|
+
end.freeze
|
|
321
|
+
@column_breaks = breaks
|
|
322
|
+
pr = protected_ranges || unmapped_data[:protected_ranges] || unmapped_data.dig(:facade, :protected_ranges) || []
|
|
323
|
+
@protected_ranges = pr.map { |r| r.is_a?(Elements::ProtectedRange) ? r : Elements::ProtectedRange.new(**r) }.freeze
|
|
114
324
|
@cell_watches = (cell_watches || unmapped_data[:cell_watches] || unmapped_data.dig(:facade, :cell_watches) || []).freeze
|
|
115
|
-
|
|
116
|
-
@
|
|
117
|
-
|
|
118
|
-
@
|
|
119
|
-
|
|
325
|
+
ie = ignored_errors || unmapped_data[:ignored_errors] || unmapped_data.dig(:facade, :ignored_errors) || []
|
|
326
|
+
@ignored_errors = ie.map { |r| r.is_a?(Elements::IgnoredError) ? r : Elements::IgnoredError.new(**r) }.freeze
|
|
327
|
+
pp = phonetic_properties || unmapped_data[:phonetic_properties] || unmapped_data.dig(:facade, :phonetic_properties)
|
|
328
|
+
@phonetic_properties = if pp.nil?
|
|
329
|
+
nil
|
|
330
|
+
elsif pp.is_a?(Elements::PhoneticProperties)
|
|
331
|
+
pp
|
|
332
|
+
else
|
|
333
|
+
Elements::PhoneticProperties.new(**pp)
|
|
334
|
+
end
|
|
335
|
+
@selection = if selection.nil?
|
|
336
|
+
nil
|
|
337
|
+
elsif selection.is_a?(Elements::Selection)
|
|
338
|
+
selection
|
|
339
|
+
elsif selection.is_a?(Array)
|
|
340
|
+
selection.map { |s| s.is_a?(Elements::Selection) ? s : Elements::Selection.new(**s) }
|
|
341
|
+
else
|
|
342
|
+
Elements::Selection.new(**selection)
|
|
343
|
+
end
|
|
344
|
+
full_calc = if @sheet_properties.respond_to?(:full_calc_on_load?)
|
|
345
|
+
@sheet_properties.full_calc_on_load?
|
|
346
|
+
elsif @sheet_properties.is_a?(Hash)
|
|
347
|
+
@sheet_properties[:full_calc_on_load]
|
|
348
|
+
end
|
|
349
|
+
calc = sheet_calc_properties || unmapped_data[:sheet_calc_properties] || unmapped_data[:sheet_calc_pr] || unmapped_data.dig(:facade, :sheet_calc_properties) || unmapped_data.dig(:facade, :sheet_calc_pr) || (full_calc ? { full_calc_on_load: true } : nil)
|
|
350
|
+
@sheet_calc_pr = if calc.nil?
|
|
351
|
+
nil
|
|
352
|
+
elsif calc.is_a?(Elements::SheetCalcProperties)
|
|
353
|
+
calc
|
|
354
|
+
else
|
|
355
|
+
Elements::SheetCalcProperties.new(**calc)
|
|
356
|
+
end
|
|
357
|
+
bg = background_image || unmapped_data[:background_image] || unmapped_data.dig(:facade, :background_image)
|
|
358
|
+
@background_image = if bg.nil?
|
|
359
|
+
nil
|
|
360
|
+
elsif bg.is_a?(Elements::BackgroundImage)
|
|
361
|
+
bg
|
|
362
|
+
else
|
|
363
|
+
Elements::BackgroundImage.new(**bg)
|
|
364
|
+
end
|
|
365
|
+
pt = pivot_tables || unmapped_data[:pivot_tables] || unmapped_data.dig(:facade, :pivot_tables) || []
|
|
366
|
+
@pivot_tables = pt.map { |r| r.is_a?(Elements::PivotTable) ? r : Elements::PivotTable.new(**r) }.freeze
|
|
367
|
+
sp = split_pane || unmapped_data[:split_pane] || unmapped_data.dig(:facade, :split_pane)
|
|
368
|
+
@split_pane = if sp.nil?
|
|
369
|
+
nil
|
|
370
|
+
elsif sp.is_a?(Elements::SplitPane)
|
|
371
|
+
sp
|
|
372
|
+
else
|
|
373
|
+
Elements::SplitPane.new(**sp)
|
|
374
|
+
end
|
|
375
|
+
fc = filter_columns || unmapped_data[:filter_columns] || unmapped_data.dig(:facade, :filter_columns) || {}
|
|
376
|
+
@filter_columns = fc.to_h do |k, v|
|
|
377
|
+
column_id = k.to_i
|
|
378
|
+
val = case v
|
|
379
|
+
when Elements::FilterColumn
|
|
380
|
+
v
|
|
381
|
+
when Hash
|
|
382
|
+
Elements::FilterColumn.from_spec(column_id, v)
|
|
383
|
+
when Array
|
|
384
|
+
Elements::FilterColumn.new(column_id: column_id, filters: v)
|
|
385
|
+
else
|
|
386
|
+
Elements::FilterColumn.new(column_id: column_id, filters: [v.to_s])
|
|
387
|
+
end
|
|
388
|
+
[column_id, val]
|
|
389
|
+
end.freeze
|
|
390
|
+
st = sort_state || unmapped_data[:sort_state] || unmapped_data.dig(:facade, :sort_state)
|
|
391
|
+
@sort_state = if st.nil?
|
|
392
|
+
nil
|
|
393
|
+
elsif st.is_a?(Elements::SortState)
|
|
394
|
+
st
|
|
395
|
+
else
|
|
396
|
+
Elements::SortState.new(**st)
|
|
397
|
+
end
|
|
398
|
+
hfi = header_footer_images || unmapped_data[:header_footer_images] || unmapped_data.dig(:facade, :header_footer_images) || []
|
|
399
|
+
@header_footer_images = hfi.map { |r| r.is_a?(Elements::HeaderFooterImage) ? r : Elements::HeaderFooterImage.new(**r) }.freeze
|
|
120
400
|
end
|
|
121
401
|
|
|
122
402
|
# Returns whether trailing empty rows are omitted during iteration.
|
|
@@ -125,19 +405,17 @@ module Xlsxrb
|
|
|
125
405
|
# @api public
|
|
126
406
|
#: () -> bool
|
|
127
407
|
def trim_empty_rows?
|
|
128
|
-
@trim_empty_rows
|
|
408
|
+
@trim_empty_rows
|
|
129
409
|
end
|
|
130
|
-
alias trim_empty_rows trim_empty_rows?
|
|
131
410
|
|
|
132
|
-
# Returns whether
|
|
411
|
+
# Returns whether empty rows are yielded for skipped row numbers during iteration.
|
|
133
412
|
#
|
|
134
413
|
# @return [Boolean]
|
|
135
414
|
# @api public
|
|
136
415
|
#: () -> bool
|
|
137
416
|
def pad_empty_rows?
|
|
138
|
-
@pad_empty_rows
|
|
417
|
+
@pad_empty_rows
|
|
139
418
|
end
|
|
140
|
-
alias pad_empty_rows pad_empty_rows?
|
|
141
419
|
|
|
142
420
|
# Returns whether missing cells within rows are padded during iteration.
|
|
143
421
|
#
|
|
@@ -145,9 +423,8 @@ module Xlsxrb
|
|
|
145
423
|
# @api public
|
|
146
424
|
#: () -> bool
|
|
147
425
|
def pad_empty_cells?
|
|
148
|
-
@pad_empty_cells
|
|
426
|
+
@pad_empty_cells
|
|
149
427
|
end
|
|
150
|
-
alias pad_empty_cells pad_empty_cells?
|
|
151
428
|
|
|
152
429
|
# Returns whether the worksheet uses the 1904 date system.
|
|
153
430
|
#
|
|
@@ -175,6 +452,7 @@ module Xlsxrb
|
|
|
175
452
|
#: () -> (String | Hash[Symbol, untyped])?
|
|
176
453
|
def tab_color
|
|
177
454
|
props = sheet_properties
|
|
455
|
+
props = props.to_h if props.is_a?(Elements::MetadataRecord)
|
|
178
456
|
return props[:tab_color] if props[:tab_color]
|
|
179
457
|
return { theme: props[:tab_color_theme], tint: props[:tab_color_tint] } if props[:tab_color_theme]
|
|
180
458
|
return { indexed: props[:tab_color_indexed] } if props[:tab_color_indexed]
|
|
@@ -189,7 +467,7 @@ module Xlsxrb
|
|
|
189
467
|
# @api public
|
|
190
468
|
#: () -> String?
|
|
191
469
|
def code_name
|
|
192
|
-
sheet_properties
|
|
470
|
+
sheet_properties.code_name
|
|
193
471
|
end
|
|
194
472
|
|
|
195
473
|
# Returns whether fit-to-page is enabled for page setup on this worksheet.
|
|
@@ -198,9 +476,8 @@ module Xlsxrb
|
|
|
198
476
|
# @api public
|
|
199
477
|
#: () -> bool
|
|
200
478
|
def fit_to_page?
|
|
201
|
-
sheet_properties
|
|
479
|
+
sheet_properties.fit_to_page?
|
|
202
480
|
end
|
|
203
|
-
alias fit_to_page fit_to_page?
|
|
204
481
|
|
|
205
482
|
# Returns whether full calculation on load is enabled on this worksheet.
|
|
206
483
|
#
|
|
@@ -208,9 +485,8 @@ module Xlsxrb
|
|
|
208
485
|
# @api public
|
|
209
486
|
#: () -> bool
|
|
210
487
|
def full_calc_on_load?
|
|
211
|
-
|
|
488
|
+
@sheet_calc_pr&.to_h&.[](:full_calc_on_load) == true || sheet_properties.to_h[:full_calc_on_load] == true
|
|
212
489
|
end
|
|
213
|
-
alias full_calc_on_load full_calc_on_load?
|
|
214
490
|
|
|
215
491
|
# Returns the outline and grouping properties of the worksheet, or an empty hash if none configured.
|
|
216
492
|
#
|
|
@@ -219,6 +495,7 @@ module Xlsxrb
|
|
|
219
495
|
#: () -> Hash[Symbol, untyped]
|
|
220
496
|
def outline_properties
|
|
221
497
|
props = sheet_properties
|
|
498
|
+
props = props.to_h if props.is_a?(Elements::MetadataRecord)
|
|
222
499
|
return props[:outline_properties] if props[:outline_properties]
|
|
223
500
|
|
|
224
501
|
res = {}
|
|
@@ -228,7 +505,6 @@ module Xlsxrb
|
|
|
228
505
|
res[:apply_styles] = props[:apply_styles] unless props[:apply_styles].nil?
|
|
229
506
|
res
|
|
230
507
|
end
|
|
231
|
-
alias outline_pr outline_properties
|
|
232
508
|
|
|
233
509
|
# Iterate over rows in the worksheet.
|
|
234
510
|
#
|
|
@@ -324,7 +600,7 @@ module Xlsxrb
|
|
|
324
600
|
row_consumer = lambda do |row|
|
|
325
601
|
while current_expected_idx < row.index
|
|
326
602
|
empty_row = Row.new(index: current_expected_idx)
|
|
327
|
-
inner_consumer.call(pad_cells ? empty_row.
|
|
603
|
+
inner_consumer.call(pad_cells ? empty_row.padded : empty_row)
|
|
328
604
|
current_expected_idx += 1
|
|
329
605
|
end
|
|
330
606
|
inner_consumer.call(row)
|
|
@@ -333,7 +609,7 @@ module Xlsxrb
|
|
|
333
609
|
end
|
|
334
610
|
|
|
335
611
|
rows.each do |row|
|
|
336
|
-
row_to_yield = pad_cells ? row.
|
|
612
|
+
row_to_yield = pad_cells ? row.padded : row
|
|
337
613
|
row_consumer.call(row_to_yield)
|
|
338
614
|
end
|
|
339
615
|
end
|
|
@@ -384,34 +660,18 @@ module Xlsxrb
|
|
|
384
660
|
# Returns all images anchored at a specific cell reference or 0-based coordinate.
|
|
385
661
|
#
|
|
386
662
|
# @param ref_or_row [String, Symbol, Integer] Cell reference (e.g. "A1") or 0-based row index.
|
|
387
|
-
# @param col [Integer, nil] Optional 0-based column index.
|
|
663
|
+
# @param col [Integer, String, Symbol, nil] Optional 0-based column index or column letter/Symbol.
|
|
388
664
|
# @return [Array<Elements::Image>]
|
|
389
665
|
# @api public
|
|
390
|
-
#: (String | Symbol | Integer ref_or_row, ?Integer
|
|
666
|
+
#: (String | Symbol | Integer ref_or_row, ?Integer | String | Symbol | nil col) -> Array[Elements::Image]
|
|
391
667
|
def images_at(ref_or_row, col = nil)
|
|
392
668
|
ref = if col
|
|
393
|
-
|
|
669
|
+
c_idx = col.is_a?(Integer) ? col : Cell._column_index(col)
|
|
670
|
+
"#{Cell._column_letter(c_idx)}#{ref_or_row.to_i + 1}"
|
|
394
671
|
else
|
|
395
672
|
ref_or_row.to_s.upcase
|
|
396
673
|
end
|
|
397
|
-
images.select { |img| img.
|
|
398
|
-
end
|
|
399
|
-
|
|
400
|
-
# Yields self with images loaded or returns self.
|
|
401
|
-
#
|
|
402
|
-
# @yield [sheet]
|
|
403
|
-
# @yieldparam sheet [Elements::Worksheet]
|
|
404
|
-
# @return [Elements::Worksheet, void]
|
|
405
|
-
# @api public
|
|
406
|
-
#: () { (Elements::Worksheet) -> void } -> void
|
|
407
|
-
#: () -> Elements::Worksheet
|
|
408
|
-
def with_images
|
|
409
|
-
if block_given?
|
|
410
|
-
yield self
|
|
411
|
-
nil
|
|
412
|
-
else
|
|
413
|
-
self
|
|
414
|
-
end
|
|
674
|
+
images.select { |img| img.ref == ref }
|
|
415
675
|
end
|
|
416
676
|
|
|
417
677
|
# Returns whether the worksheet is valid according to OOXML specifications.
|
|
@@ -452,13 +712,14 @@ module Xlsxrb
|
|
|
452
712
|
# Returns hyperlink metadata for the given cell reference, or nil.
|
|
453
713
|
#
|
|
454
714
|
# @param ref_or_row [String, Symbol, Integer] Cell reference (e.g. "A1") or 0-based row index.
|
|
455
|
-
# @param col [Integer, nil] Optional 0-based column index
|
|
456
|
-
# @return [
|
|
715
|
+
# @param col [Integer, String, Symbol, nil] Optional 0-based column index or column letter/Symbol.
|
|
716
|
+
# @return [Elements::Hyperlink, nil]
|
|
457
717
|
# @api public
|
|
458
|
-
#: (String | Symbol | Integer ref_or_row, ?Integer
|
|
718
|
+
#: (String | Symbol | Integer | nil ref_or_row, ?Integer | String | Symbol | nil col) -> Elements::Hyperlink?
|
|
459
719
|
def hyperlink(ref_or_row, col = nil)
|
|
460
720
|
ref = if col
|
|
461
|
-
|
|
721
|
+
c_idx = Cell._column_index(col)
|
|
722
|
+
"#{Cell._column_letter(c_idx)}#{ref_or_row.to_i + 1}"
|
|
462
723
|
else
|
|
463
724
|
ref_or_row.to_s.upcase
|
|
464
725
|
end
|
|
@@ -468,13 +729,14 @@ module Xlsxrb
|
|
|
468
729
|
# Returns comment metadata for the given cell reference, or nil.
|
|
469
730
|
#
|
|
470
731
|
# @param ref_or_row [String, Symbol, Integer] Cell reference (e.g. "A1") or 0-based row index.
|
|
471
|
-
# @param col [Integer, nil] Optional 0-based column index
|
|
472
|
-
# @return [
|
|
732
|
+
# @param col [Integer, String, Symbol, nil] Optional 0-based column index or column letter/Symbol.
|
|
733
|
+
# @return [Elements::Comment, nil]
|
|
473
734
|
# @api public
|
|
474
|
-
#: (String | Symbol | Integer ref_or_row, ?Integer
|
|
735
|
+
#: (String | Symbol | Integer | nil ref_or_row, ?Integer | String | Symbol | nil col) -> Elements::Comment?
|
|
475
736
|
def comment(ref_or_row, col = nil)
|
|
476
737
|
ref = if col
|
|
477
|
-
|
|
738
|
+
c_idx = Cell._column_index(col)
|
|
739
|
+
"#{Cell._column_letter(c_idx)}#{ref_or_row.to_i + 1}"
|
|
478
740
|
else
|
|
479
741
|
ref_or_row.to_s.upcase
|
|
480
742
|
end
|
|
@@ -483,26 +745,44 @@ module Xlsxrb
|
|
|
483
745
|
|
|
484
746
|
# Returns comments indexed by cell reference.
|
|
485
747
|
#
|
|
486
|
-
# @return [Hash<String,
|
|
748
|
+
# @return [Hash<String, Elements::Comment>]
|
|
487
749
|
# @api public
|
|
488
|
-
#: () -> Hash[String,
|
|
750
|
+
#: () -> Hash[String, Elements::Comment]
|
|
489
751
|
def comments_by_ref
|
|
490
752
|
@comments_by_ref ||= @comments.each_with_object({}) do |c, acc|
|
|
491
|
-
r = c[:ref] || c[:cell]
|
|
753
|
+
r = c.respond_to?(:ref) ? c.ref : (c[:ref] || c[:cell])
|
|
492
754
|
acc[r.to_s.upcase] = c if r
|
|
493
755
|
end
|
|
494
756
|
end
|
|
495
757
|
|
|
496
|
-
# Returns threaded
|
|
758
|
+
# Returns the root threaded comment for the given cell reference, or nil.
|
|
497
759
|
#
|
|
498
760
|
# @param ref_or_row [String, Symbol, Integer] Cell reference (e.g. "A1") or 0-based row index.
|
|
499
|
-
# @param col [Integer, nil] Optional 0-based column index.
|
|
500
|
-
# @return [
|
|
761
|
+
# @param col [Integer, String, Symbol, nil] Optional 0-based column index or column letter/Symbol.
|
|
762
|
+
# @return [Elements::ThreadedComment, nil]
|
|
501
763
|
# @api public
|
|
502
|
-
#: (String | Symbol | Integer ref_or_row, ?Integer
|
|
764
|
+
#: (String | Symbol | Integer ref_or_row, ?Integer | String | Symbol | nil col) -> Elements::ThreadedComment?
|
|
503
765
|
def threaded_comment(ref_or_row, col = nil)
|
|
504
766
|
ref = if col
|
|
505
|
-
|
|
767
|
+
c_idx = col.is_a?(Integer) ? col : Cell._column_index(col)
|
|
768
|
+
"#{Cell._column_letter(c_idx)}#{ref_or_row.to_i + 1}"
|
|
769
|
+
else
|
|
770
|
+
ref_or_row.to_s.upcase
|
|
771
|
+
end
|
|
772
|
+
threaded_comments_by_ref[ref]&.first
|
|
773
|
+
end
|
|
774
|
+
|
|
775
|
+
# Returns threaded comments for the given cell reference, or empty array.
|
|
776
|
+
#
|
|
777
|
+
# @param ref_or_row [String, Symbol, Integer] Cell reference (e.g. "A1") or 0-based row index.
|
|
778
|
+
# @param col [Integer, String, Symbol, nil] Optional 0-based column index or column letter/Symbol.
|
|
779
|
+
# @return [Array<Elements::ThreadedComment>]
|
|
780
|
+
# @api public
|
|
781
|
+
#: (String | Symbol | Integer ref_or_row, ?Integer | String | Symbol | nil col) -> Array[Elements::ThreadedComment]
|
|
782
|
+
def threaded_comments_at(ref_or_row, col = nil)
|
|
783
|
+
ref = if col
|
|
784
|
+
c_idx = col.is_a?(Integer) ? col : Cell._column_index(col)
|
|
785
|
+
"#{Cell._column_letter(c_idx)}#{ref_or_row.to_i + 1}"
|
|
506
786
|
else
|
|
507
787
|
ref_or_row.to_s.upcase
|
|
508
788
|
end
|
|
@@ -511,12 +791,12 @@ module Xlsxrb
|
|
|
511
791
|
|
|
512
792
|
# Returns threaded comments indexed by cell reference.
|
|
513
793
|
#
|
|
514
|
-
# @return [Hash<String, Array<
|
|
794
|
+
# @return [Hash<String, Array<Elements::ThreadedComment>>]
|
|
515
795
|
# @api public
|
|
516
|
-
#: () -> Hash[String, Array[
|
|
796
|
+
#: () -> Hash[String, Array[Elements::ThreadedComment]]
|
|
517
797
|
def threaded_comments_by_ref
|
|
518
798
|
@threaded_comments_by_ref ||= @threaded_comments.each_with_object({}) do |c, acc|
|
|
519
|
-
r = c[:ref] || c[:cell]
|
|
799
|
+
r = c.respond_to?(:ref) ? c.ref : (c[:ref] || c[:cell])
|
|
520
800
|
(acc[r.to_s.upcase] ||= []) << c if r
|
|
521
801
|
end
|
|
522
802
|
end
|
|
@@ -524,86 +804,18 @@ module Xlsxrb
|
|
|
524
804
|
# Access a cell by reference or 0-based coordinates.
|
|
525
805
|
#
|
|
526
806
|
# @param ref_or_row [String, Symbol, Integer] Cell reference (e.g. "A1") or 0-based row index.
|
|
527
|
-
# @param col [Integer, nil] Optional 0-based column index.
|
|
807
|
+
# @param col [Integer, String, Symbol, nil] Optional 0-based column index or column letter/Symbol.
|
|
528
808
|
# @return [Elements::Cell, nil]
|
|
529
809
|
# @api public
|
|
530
|
-
#: (String | Symbol | Integer ref_or_row, ?Integer? col) -> Elements::Cell?
|
|
531
|
-
def cell(ref_or_row, col = nil)
|
|
532
|
-
if col
|
|
533
|
-
row = row_at(ref_or_row.to_i)
|
|
534
|
-
row&.cell_at(col.to_i)
|
|
535
|
-
else
|
|
536
|
-
self[ref_or_row]
|
|
537
|
-
end
|
|
538
|
-
end
|
|
539
|
-
|
|
540
810
|
# Returns the formatted string representation of a cell's value.
|
|
541
811
|
#
|
|
542
812
|
# @param ref_or_row [String, Symbol, Integer] Cell reference (e.g. "A1") or 0-based row index.
|
|
543
|
-
# @param col [Integer, nil] Optional 0-based column index.
|
|
813
|
+
# @param col [Integer, String, Symbol, nil] Optional 0-based column index or column letter/Symbol.
|
|
544
814
|
# @return [String, nil]
|
|
545
815
|
# @api public
|
|
546
|
-
#: (String | Symbol | Integer ref_or_row, ?Integer
|
|
816
|
+
#: (String | Symbol | Integer ref_or_row, ?Integer | String | Symbol | nil col) -> String?
|
|
547
817
|
def formatted_value(ref_or_row, col = nil)
|
|
548
|
-
|
|
549
|
-
end
|
|
550
|
-
|
|
551
|
-
# Returns a new Worksheet with the specified cell updated.
|
|
552
|
-
#
|
|
553
|
-
# @example
|
|
554
|
-
# new_sheet = sheet.update_cell("B1", value: "Updated")
|
|
555
|
-
#
|
|
556
|
-
# @param ref [String] The cell reference (e.g. "B1").
|
|
557
|
-
# @param value [Object] The new cell value.
|
|
558
|
-
# @param style_index [Integer, String, nil] Optional new style index.
|
|
559
|
-
# @param formula [Elements::Formula, nil] Optional new formula.
|
|
560
|
-
# @param hyperlink [Hash, String, nil] Optional new hyperlink.
|
|
561
|
-
# @param comment [Hash, String, nil] Optional new comment.
|
|
562
|
-
# @return [Worksheet] A new Worksheet instance.
|
|
563
|
-
# @api public
|
|
564
|
-
#: (String ref, ?value: untyped, ?style_index: Integer | String | nil, ?formula: Elements::Formula?, ?hyperlink: (Hash[Symbol, untyped] | String)?, ?comment: (Hash[Symbol, untyped] | String)?) -> Elements::Worksheet
|
|
565
|
-
def update_cell(ref, value: nil, style_index: nil, formula: nil, hyperlink: nil, comment: nil)
|
|
566
|
-
parsed = Cell.parse_ref(ref)
|
|
567
|
-
raise ArgumentError, "invalid cell reference: #{ref}" unless parsed
|
|
568
|
-
|
|
569
|
-
row_idx, col_idx = parsed
|
|
570
|
-
existing_row = row_at(row_idx)
|
|
571
|
-
|
|
572
|
-
if existing_row
|
|
573
|
-
existing_cell = existing_row.cell_at(col_idx)
|
|
574
|
-
new_cell = if existing_cell
|
|
575
|
-
existing_cell.with(
|
|
576
|
-
value: value || existing_cell.value,
|
|
577
|
-
style_index: style_index || existing_cell.style_index,
|
|
578
|
-
formula: formula || existing_cell.formula,
|
|
579
|
-
hyperlink: hyperlink || existing_cell.hyperlink,
|
|
580
|
-
comment: comment || existing_cell.comment
|
|
581
|
-
)
|
|
582
|
-
else
|
|
583
|
-
Cell.new(row_index: row_idx, column_index: col_idx, value: value, style_index: style_index, formula: formula, hyperlink: hyperlink, comment: comment)
|
|
584
|
-
end
|
|
585
|
-
|
|
586
|
-
# Replace cell in the existing row
|
|
587
|
-
new_cells = existing_row.cells.reject { |c| c.column_index == col_idx }
|
|
588
|
-
new_cells << new_cell
|
|
589
|
-
new_cells.sort_by!(&:column_index)
|
|
590
|
-
|
|
591
|
-
new_row = existing_row.with(cells: new_cells)
|
|
592
|
-
new_rows = rows.map { |r| r.index == row_idx ? new_row : r }
|
|
593
|
-
else
|
|
594
|
-
# Row doesn't exist, create it
|
|
595
|
-
new_cell = Cell.new(row_index: row_idx, column_index: col_idx, value: value, style_index: style_index, formula: formula, hyperlink: hyperlink, comment: comment)
|
|
596
|
-
new_row = Row.new(index: row_idx, cells: [new_cell])
|
|
597
|
-
new_rows = (rows + [new_row]).sort_by!(&:index)
|
|
598
|
-
end
|
|
599
|
-
new_hyperlinks = hyperlink ? hyperlinks.merge(ref.upcase => hyperlink) : hyperlinks
|
|
600
|
-
new_comments = if comment
|
|
601
|
-
entry = comment.is_a?(Hash) ? comment.merge(ref: ref.upcase) : { ref: ref.upcase, text: comment }
|
|
602
|
-
@comments.reject { |c| (c[:ref] || c[:cell])&.to_s&.upcase == ref.upcase } + [entry]
|
|
603
|
-
else
|
|
604
|
-
@comments
|
|
605
|
-
end
|
|
606
|
-
with(rows: new_rows, hyperlinks: new_hyperlinks, comments: new_comments)
|
|
818
|
+
self[ref_or_row, col]&.formatted_value
|
|
607
819
|
end
|
|
608
820
|
|
|
609
821
|
# Returns a new Worksheet with attributes replaced (Data-like behavior).
|
|
@@ -617,31 +829,49 @@ module Xlsxrb
|
|
|
617
829
|
new_rows = changes.key?(:rows) ? changes[:rows] : rows
|
|
618
830
|
new_cols = changes.key?(:columns) ? changes[:columns] : columns
|
|
619
831
|
new_charts = changes.key?(:charts) ? changes[:charts] : charts
|
|
620
|
-
new_cf =
|
|
621
|
-
changes[:conditional_formatting]
|
|
622
|
-
elsif changes.key?(:conditional_formats)
|
|
623
|
-
changes[:conditional_formats]
|
|
624
|
-
else
|
|
625
|
-
conditional_formatting
|
|
626
|
-
end
|
|
832
|
+
new_cf = changes.key?(:conditional_formats) ? changes[:conditional_formats] : conditional_formats
|
|
627
833
|
new_dv = changes.key?(:data_validations) ? changes[:data_validations] : data_validations
|
|
628
834
|
new_unmapped = changes.key?(:unmapped_data) ? changes[:unmapped_data] : unmapped_data
|
|
835
|
+
if new_unmapped.is_a?(Hash) && new_unmapped[:facade].is_a?(Hash)
|
|
836
|
+
stale_keys = changes.keys.select { |k| new_unmapped[:facade].key?(k) }
|
|
837
|
+
stale_keys << :col_breaks if changes.key?(:column_breaks) && new_unmapped[:facade].key?(:col_breaks)
|
|
838
|
+
stale_keys << :sheet_calc_pr if changes.key?(:sheet_calc_properties) && new_unmapped[:facade].key?(:sheet_calc_pr)
|
|
839
|
+
stale_keys << :merge_cells if changes.key?(:merged_cells) && new_unmapped[:facade].key?(:merge_cells)
|
|
840
|
+
unless stale_keys.empty?
|
|
841
|
+
new_unmapped = new_unmapped.dup
|
|
842
|
+
new_facade = new_unmapped[:facade].dup
|
|
843
|
+
stale_keys.each { |k| new_facade.delete(k) }
|
|
844
|
+
new_unmapped[:facade] = new_facade
|
|
845
|
+
end
|
|
846
|
+
end
|
|
629
847
|
new_errors = changes.key?(:errors) ? changes[:errors] : errors
|
|
630
848
|
new_state = changes.key?(:state) ? changes[:state] : state
|
|
631
849
|
new_hyperlinks = changes.key?(:hyperlinks) ? changes[:hyperlinks] : hyperlinks
|
|
632
850
|
new_comments = changes.key?(:comments) ? changes[:comments] : comments
|
|
633
851
|
new_styles = changes.key?(:styles) ? changes[:styles] : styles
|
|
634
|
-
new_date1904 = changes.key?(:date1904) ? changes[:date1904] : date1904
|
|
635
|
-
new_dim = changes.key?(:dimension)
|
|
852
|
+
new_date1904 = changes.key?(:date1904) ? changes[:date1904] : date1904?
|
|
853
|
+
new_dim = if changes.key?(:dimension)
|
|
854
|
+
changes[:dimension]
|
|
855
|
+
else
|
|
856
|
+
(changes.key?(:rows) ? nil : @dimension)
|
|
857
|
+
end
|
|
636
858
|
new_print_area = changes.key?(:print_area) ? changes[:print_area] : print_area
|
|
637
859
|
new_print_titles = changes.key?(:print_titles) ? changes[:print_titles] : print_titles
|
|
638
860
|
new_sparklines = changes.key?(:sparkline_groups) ? changes[:sparkline_groups] : sparkline_groups
|
|
639
861
|
new_trim = changes.key?(:trim_empty_rows) ? changes[:trim_empty_rows] : @trim_empty_rows
|
|
862
|
+
new_pad_rows = changes.key?(:pad_empty_rows) ? changes[:pad_empty_rows] : @pad_empty_rows
|
|
863
|
+
new_pad_cells = changes.key?(:pad_empty_cells) ? changes[:pad_empty_cells] : @pad_empty_cells
|
|
864
|
+
new_images = changes.key?(:images) ? changes[:images] : images
|
|
640
865
|
new_merged = changes.key?(:merged_cells) ? changes[:merged_cells] : merged_cells
|
|
641
866
|
new_auto_filter = changes.key?(:auto_filter) ? changes[:auto_filter] : auto_filter
|
|
642
867
|
new_tables = changes.key?(:tables) ? changes[:tables] : tables
|
|
643
868
|
new_shapes = changes.key?(:shapes) ? changes[:shapes] : shapes
|
|
644
869
|
new_freeze_pane = changes.key?(:freeze_pane) ? changes[:freeze_pane] : freeze_pane
|
|
870
|
+
new_split_pane = changes.key?(:split_pane) ? changes[:split_pane] : split_pane
|
|
871
|
+
new_pivot_tables = changes.key?(:pivot_tables) ? changes[:pivot_tables] : pivot_tables
|
|
872
|
+
new_filter_columns = changes.key?(:filter_columns) ? changes[:filter_columns] : filter_columns
|
|
873
|
+
new_sort_state = changes.key?(:sort_state) ? changes[:sort_state] : sort_state
|
|
874
|
+
new_header_footer_images = changes.key?(:header_footer_images) ? changes[:header_footer_images] : header_footer_images
|
|
645
875
|
new_page_setup = changes.key?(:page_setup) ? changes[:page_setup] : page_setup
|
|
646
876
|
new_page_margins = changes.key?(:page_margins) ? changes[:page_margins] : page_margins
|
|
647
877
|
new_header_footer = changes.key?(:header_footer) ? changes[:header_footer] : header_footer
|
|
@@ -651,28 +881,14 @@ module Xlsxrb
|
|
|
651
881
|
new_sheet_properties = changes.key?(:sheet_properties) ? changes[:sheet_properties] : sheet_properties
|
|
652
882
|
new_sheet_format = changes.key?(:sheet_format) ? changes[:sheet_format] : sheet_format
|
|
653
883
|
new_row_breaks = changes.key?(:row_breaks) ? changes[:row_breaks] : row_breaks
|
|
654
|
-
new_col_breaks = changes.key?(:
|
|
884
|
+
new_col_breaks = changes.key?(:column_breaks) ? changes[:column_breaks] : @column_breaks
|
|
655
885
|
new_protected_ranges = changes.key?(:protected_ranges) ? changes[:protected_ranges] : protected_ranges
|
|
656
886
|
new_cell_watches = changes.key?(:cell_watches) ? changes[:cell_watches] : cell_watches
|
|
657
887
|
new_ignored_errors = changes.key?(:ignored_errors) ? changes[:ignored_errors] : ignored_errors
|
|
658
|
-
new_phonetic_properties =
|
|
659
|
-
changes[:phonetic_properties]
|
|
660
|
-
elsif changes.key?(:phonetic_pr)
|
|
661
|
-
changes[:phonetic_pr]
|
|
662
|
-
else
|
|
663
|
-
phonetic_properties
|
|
664
|
-
end
|
|
888
|
+
new_phonetic_properties = changes.key?(:phonetic_properties) ? changes[:phonetic_properties] : phonetic_properties
|
|
665
889
|
new_selection = changes.key?(:selection) ? changes[:selection] : selection
|
|
666
|
-
|
|
667
|
-
new_background_image =
|
|
668
|
-
changes[:background_image]
|
|
669
|
-
elsif changes.key?(:background_picture)
|
|
670
|
-
changes[:background_picture]
|
|
671
|
-
elsif changes.key?(:picture)
|
|
672
|
-
changes[:picture]
|
|
673
|
-
else
|
|
674
|
-
background_image
|
|
675
|
-
end
|
|
890
|
+
new_sheet_calc_properties = changes.key?(:sheet_calc_properties) ? changes[:sheet_calc_properties] : @sheet_calc_pr
|
|
891
|
+
new_background_image = changes.key?(:background_image) ? changes[:background_image] : background_image
|
|
676
892
|
new_threaded_comments = changes.key?(:threaded_comments) ? changes[:threaded_comments] : threaded_comments
|
|
677
893
|
|
|
678
894
|
self.class.new(
|
|
@@ -680,13 +896,14 @@ module Xlsxrb
|
|
|
680
896
|
rows: new_rows,
|
|
681
897
|
columns: new_cols,
|
|
682
898
|
charts: new_charts,
|
|
683
|
-
|
|
899
|
+
conditional_formats: new_cf,
|
|
684
900
|
data_validations: new_dv,
|
|
685
901
|
unmapped_data: new_unmapped,
|
|
686
902
|
errors: new_errors,
|
|
687
903
|
state: new_state,
|
|
688
904
|
hyperlinks: new_hyperlinks,
|
|
689
905
|
comments: new_comments,
|
|
906
|
+
images: new_images,
|
|
690
907
|
styles: new_styles,
|
|
691
908
|
date1904: new_date1904,
|
|
692
909
|
dimension: new_dim,
|
|
@@ -694,11 +911,18 @@ module Xlsxrb
|
|
|
694
911
|
print_titles: new_print_titles,
|
|
695
912
|
sparkline_groups: new_sparklines,
|
|
696
913
|
trim_empty_rows: new_trim,
|
|
914
|
+
pad_empty_rows: new_pad_rows,
|
|
915
|
+
pad_empty_cells: new_pad_cells,
|
|
697
916
|
merged_cells: new_merged,
|
|
698
917
|
auto_filter: new_auto_filter,
|
|
699
918
|
tables: new_tables,
|
|
700
919
|
shapes: new_shapes,
|
|
701
920
|
freeze_pane: new_freeze_pane,
|
|
921
|
+
split_pane: new_split_pane,
|
|
922
|
+
pivot_tables: new_pivot_tables,
|
|
923
|
+
filter_columns: new_filter_columns,
|
|
924
|
+
sort_state: new_sort_state,
|
|
925
|
+
header_footer_images: new_header_footer_images,
|
|
702
926
|
page_setup: new_page_setup,
|
|
703
927
|
page_margins: new_page_margins,
|
|
704
928
|
header_footer: new_header_footer,
|
|
@@ -708,13 +932,13 @@ module Xlsxrb
|
|
|
708
932
|
sheet_properties: new_sheet_properties,
|
|
709
933
|
sheet_format: new_sheet_format,
|
|
710
934
|
row_breaks: new_row_breaks,
|
|
711
|
-
|
|
935
|
+
column_breaks: new_col_breaks,
|
|
712
936
|
protected_ranges: new_protected_ranges,
|
|
713
937
|
cell_watches: new_cell_watches,
|
|
714
938
|
ignored_errors: new_ignored_errors,
|
|
715
939
|
phonetic_properties: new_phonetic_properties,
|
|
716
940
|
selection: new_selection,
|
|
717
|
-
|
|
941
|
+
sheet_calc_properties: new_sheet_calc_properties,
|
|
718
942
|
background_image: new_background_image,
|
|
719
943
|
threaded_comments: new_threaded_comments
|
|
720
944
|
)
|
|
@@ -728,8 +952,7 @@ module Xlsxrb
|
|
|
728
952
|
rows: rows,
|
|
729
953
|
columns: columns,
|
|
730
954
|
charts: charts,
|
|
731
|
-
|
|
732
|
-
conditional_formats: conditional_formatting,
|
|
955
|
+
conditional_formats: conditional_formats,
|
|
733
956
|
data_validations: data_validations,
|
|
734
957
|
unmapped_data: unmapped_data,
|
|
735
958
|
errors: errors,
|
|
@@ -738,17 +961,25 @@ module Xlsxrb
|
|
|
738
961
|
comments: comments,
|
|
739
962
|
threaded_comments: threaded_comments,
|
|
740
963
|
styles: styles,
|
|
741
|
-
date1904: date1904
|
|
964
|
+
date1904: date1904?,
|
|
742
965
|
dimension: dimension,
|
|
743
966
|
print_area: print_area,
|
|
744
967
|
print_titles: print_titles,
|
|
745
968
|
sparkline_groups: sparkline_groups,
|
|
746
969
|
trim_empty_rows: @trim_empty_rows,
|
|
970
|
+
pad_empty_rows: @pad_empty_rows,
|
|
971
|
+
pad_empty_cells: @pad_empty_cells,
|
|
747
972
|
merged_cells: merged_cells,
|
|
748
973
|
auto_filter: auto_filter,
|
|
749
974
|
tables: tables,
|
|
750
975
|
shapes: shapes,
|
|
751
976
|
freeze_pane: freeze_pane,
|
|
977
|
+
split_pane: split_pane,
|
|
978
|
+
pivot_tables: pivot_tables,
|
|
979
|
+
filter_columns: filter_columns,
|
|
980
|
+
sort_state: sort_state,
|
|
981
|
+
images: images,
|
|
982
|
+
header_footer_images: header_footer_images,
|
|
752
983
|
page_setup: page_setup,
|
|
753
984
|
page_margins: page_margins,
|
|
754
985
|
header_footer: header_footer,
|
|
@@ -758,19 +989,15 @@ module Xlsxrb
|
|
|
758
989
|
sheet_properties: sheet_properties,
|
|
759
990
|
sheet_format: sheet_format,
|
|
760
991
|
row_breaks: row_breaks,
|
|
761
|
-
|
|
992
|
+
column_breaks: column_breaks,
|
|
762
993
|
protected_ranges: protected_ranges,
|
|
763
994
|
cell_watches: cell_watches,
|
|
764
995
|
ignored_errors: ignored_errors,
|
|
765
996
|
phonetic_properties: phonetic_properties,
|
|
766
|
-
phonetic_pr: phonetic_properties,
|
|
767
997
|
selection: selection,
|
|
768
|
-
|
|
769
|
-
calc_pr: sheet_calc_pr,
|
|
998
|
+
sheet_calc_properties: sheet_calc_properties,
|
|
770
999
|
code_name: code_name,
|
|
771
|
-
background_image: background_image
|
|
772
|
-
background_picture: background_image,
|
|
773
|
-
picture: background_image
|
|
1000
|
+
background_image: background_image
|
|
774
1001
|
}
|
|
775
1002
|
end
|
|
776
1003
|
|
|
@@ -780,7 +1007,7 @@ module Xlsxrb
|
|
|
780
1007
|
return false unless other.is_a?(Worksheet)
|
|
781
1008
|
|
|
782
1009
|
name == other.name && rows == other.rows && columns == other.columns && charts == other.charts &&
|
|
783
|
-
|
|
1010
|
+
conditional_formats == other.conditional_formats && data_validations == other.data_validations &&
|
|
784
1011
|
state == other.state && hyperlinks == other.hyperlinks && comments == other.comments &&
|
|
785
1012
|
threaded_comments == other.threaded_comments &&
|
|
786
1013
|
merged_cells == other.merged_cells && auto_filter == other.auto_filter &&
|
|
@@ -789,10 +1016,10 @@ module Xlsxrb
|
|
|
789
1016
|
header_footer == other.header_footer && print_options == other.print_options &&
|
|
790
1017
|
sheet_protection == other.sheet_protection && sheet_view == other.sheet_view &&
|
|
791
1018
|
sheet_properties == other.sheet_properties && sheet_format == other.sheet_format &&
|
|
792
|
-
row_breaks == other.row_breaks &&
|
|
1019
|
+
row_breaks == other.row_breaks && column_breaks == other.column_breaks &&
|
|
793
1020
|
protected_ranges == other.protected_ranges && cell_watches == other.cell_watches &&
|
|
794
1021
|
ignored_errors == other.ignored_errors && phonetic_properties == other.phonetic_properties &&
|
|
795
|
-
selection == other.selection &&
|
|
1022
|
+
selection == other.selection && sheet_calc_properties == other.sheet_calc_properties &&
|
|
796
1023
|
background_image == other.background_image
|
|
797
1024
|
end
|
|
798
1025
|
alias eql? ==
|
|
@@ -800,25 +1027,22 @@ module Xlsxrb
|
|
|
800
1027
|
#: () -> Integer
|
|
801
1028
|
def hash
|
|
802
1029
|
[
|
|
803
|
-
self.class, name, rows, columns, charts,
|
|
1030
|
+
self.class, name, rows, columns, charts, conditional_formats, data_validations,
|
|
804
1031
|
state, hyperlinks, comments, threaded_comments, merged_cells, auto_filter, tables, shapes, freeze_pane,
|
|
805
1032
|
page_setup, page_margins, header_footer, print_options, sheet_protection, sheet_view,
|
|
806
|
-
sheet_properties, sheet_format, row_breaks,
|
|
807
|
-
cell_watches, ignored_errors, phonetic_properties, selection,
|
|
1033
|
+
sheet_properties, sheet_format, row_breaks, column_breaks, protected_ranges,
|
|
1034
|
+
cell_watches, ignored_errors, phonetic_properties, selection, sheet_calc_properties, background_image
|
|
808
1035
|
].hash
|
|
809
1036
|
end
|
|
810
1037
|
|
|
811
|
-
# Returns self when load is called on an already in-memory Worksheet.
|
|
812
|
-
#
|
|
813
|
-
# @return [Elements::Worksheet]
|
|
814
|
-
# @api public
|
|
815
|
-
#: () -> Elements::Worksheet
|
|
816
|
-
def load
|
|
817
|
-
self
|
|
818
|
-
end
|
|
819
|
-
alias to_worksheet load
|
|
820
|
-
|
|
821
1038
|
FORBIDDEN_NAME_CHARS = %r{[\\/?*\[\]:]|[\x00-\x08\x0B\x0C\x0E-\x1F]}
|
|
1039
|
+
private_constant :FORBIDDEN_NAME_CHARS
|
|
1040
|
+
|
|
1041
|
+
# @api private
|
|
1042
|
+
#: () -> Regexp
|
|
1043
|
+
def self.forbidden_name_chars
|
|
1044
|
+
FORBIDDEN_NAME_CHARS
|
|
1045
|
+
end
|
|
822
1046
|
|
|
823
1047
|
# Returns whether the worksheet name is valid according to OOXML specifications (1..31 chars, no forbidden chars).
|
|
824
1048
|
#
|
|
@@ -839,6 +1063,7 @@ module Xlsxrb
|
|
|
839
1063
|
# @param name [String]
|
|
840
1064
|
# @param rows [Array<Elements::Row>]
|
|
841
1065
|
# @return [Array<String>] List of errors.
|
|
1066
|
+
# @api private
|
|
842
1067
|
#: (untyped name, untyped rows) -> Array[String]
|
|
843
1068
|
def self.validate(name, rows)
|
|
844
1069
|
errs = []
|
|
@@ -885,8 +1110,8 @@ module Xlsxrb
|
|
|
885
1110
|
|
|
886
1111
|
return nil if min_r.nil? || min_c.nil?
|
|
887
1112
|
|
|
888
|
-
start_cell = "#{Elements::Cell.
|
|
889
|
-
end_cell = "#{Elements::Cell.
|
|
1113
|
+
start_cell = "#{Elements::Cell._column_letter(min_c)}#{min_r + 1}"
|
|
1114
|
+
end_cell = "#{Elements::Cell._column_letter(max_c)}#{max_r + 1}"
|
|
890
1115
|
start_cell == end_cell ? start_cell : "#{start_cell}:#{end_cell}"
|
|
891
1116
|
end
|
|
892
1117
|
end
|