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
|
@@ -6,18 +6,13 @@ module Xlsxrb
|
|
|
6
6
|
#
|
|
7
7
|
# @api private
|
|
8
8
|
module DslHelpers
|
|
9
|
-
# Normalizes merge cell range string
|
|
10
|
-
#
|
|
11
|
-
# @param range [String
|
|
12
|
-
# @param row [Integer, nil]
|
|
13
|
-
# @param col_start [Integer, String, nil]
|
|
14
|
-
# @param col_end [Integer, String, nil]
|
|
15
|
-
# @param row_start [Integer, nil]
|
|
16
|
-
# @param row_end [Integer, nil]
|
|
9
|
+
# Normalizes merge cell range string into a canonical range reference (e.g. "A1:C3").
|
|
10
|
+
#
|
|
11
|
+
# @param range [String]
|
|
17
12
|
# @param strict_excel_mode [Boolean]
|
|
18
13
|
# @return [String]
|
|
19
|
-
# : (
|
|
20
|
-
def self.normalize_merge_range: (
|
|
14
|
+
# : (String range, ?strict_excel_mode: bool) -> String
|
|
15
|
+
def self.normalize_merge_range: (String range, ?strict_excel_mode: bool) -> String
|
|
21
16
|
|
|
22
17
|
# Normalizes sheet protection options and hashes plain-text password if supplied.
|
|
23
18
|
#
|
|
@@ -26,6 +21,15 @@ module Xlsxrb
|
|
|
26
21
|
# : (Hash[Symbol, untyped] opts) -> Hash[Symbol, untyped]
|
|
27
22
|
def self.normalize_protection_options: (Hash[Symbol, untyped] opts) -> Hash[Symbol, untyped]
|
|
28
23
|
|
|
24
|
+
# Normalizes workbook protection options. A plain-text +password+ is hashed into
|
|
25
|
+
# algorithm_name, hash_value, salt_value, and spin_count (as for sheet protection); a
|
|
26
|
+
# legacy 4-digit hexadecimal hash is kept as workbook_password.
|
|
27
|
+
#
|
|
28
|
+
# @param opts [Hash]
|
|
29
|
+
# @return [Hash]
|
|
30
|
+
# : (Hash[Symbol, untyped] opts) -> Hash[Symbol, untyped]
|
|
31
|
+
def self.normalize_workbook_protection: (Hash[Symbol, untyped] opts) -> Hash[Symbol, untyped]
|
|
32
|
+
|
|
29
33
|
# Normalizes column index or letter or Range to an array of 0-based column integers.
|
|
30
34
|
#
|
|
31
35
|
# @param index [Integer, String, Symbol, Range, Array]
|
|
@@ -82,6 +86,43 @@ module Xlsxrb
|
|
|
82
86
|
# : (untyped styles) -> untyped
|
|
83
87
|
def self.normalize_row_styles: (untyped styles) -> untyped
|
|
84
88
|
|
|
89
|
+
# Style names that select the workbook's default cell format.
|
|
90
|
+
DEFAULT_STYLE_NAMES: untyped
|
|
91
|
+
|
|
92
|
+
# Returns the candidate closest to +word+ (by DidYouMean), or nil.
|
|
93
|
+
#
|
|
94
|
+
# @param word [String, Symbol]
|
|
95
|
+
# @param candidates [Array<String, Symbol>]
|
|
96
|
+
# @return [String, nil]
|
|
97
|
+
# : (String | Symbol word, Array[String | Symbol] candidates) -> String?
|
|
98
|
+
def self.closest_name: (String | Symbol word, Array[String | Symbol] candidates) -> String?
|
|
99
|
+
|
|
100
|
+
# Raises ArgumentError when +name+ is a style name that has not been defined.
|
|
101
|
+
# Integers (style indexes), Hashes (inline styles), nil, and DEFAULT_STYLE_NAMES pass.
|
|
102
|
+
#
|
|
103
|
+
# @param name [Object] Style reference given by the caller.
|
|
104
|
+
# @param defined_names [Array<String>, Hash{String => Object}] Defined style names.
|
|
105
|
+
# @return [void]
|
|
106
|
+
# @raise [ArgumentError] if +name+ is an undefined style name.
|
|
107
|
+
# : (untyped name, untyped defined_names) -> void
|
|
108
|
+
def self.check_style_name!: (untyped name, untyped defined_names) -> void
|
|
109
|
+
|
|
110
|
+
# Number formats given to Date and Time cell values that have no format of their own.
|
|
111
|
+
DATE_NUMBER_FORMAT: ::String
|
|
112
|
+
|
|
113
|
+
TIME_NUMBER_FORMAT: ::String
|
|
114
|
+
|
|
115
|
+
# Decides whether a Date or Time value styled with +style_builder+ needs a variant of
|
|
116
|
+
# that style carrying the default date or time number format. Without it, a style such
|
|
117
|
+
# as bold: true replaces the date format and Excel shows the bare serial number.
|
|
118
|
+
#
|
|
119
|
+
# @param value [Object] Cell value.
|
|
120
|
+
# @param style_name [String] Name of the cell's style.
|
|
121
|
+
# @param style_builder [StyleBuilder, nil] The style's definition.
|
|
122
|
+
# @return [Array(String, String), nil] Variant style name and number format, or nil.
|
|
123
|
+
# : (untyped value, String style_name, StyleBuilder? style_builder) -> [String, String]?
|
|
124
|
+
def self.date_style_variant: (untyped value, String style_name, StyleBuilder? style_builder) -> [ String, String ]?
|
|
125
|
+
|
|
85
126
|
# Validates row index and height against Excel limits in strict mode.
|
|
86
127
|
#
|
|
87
128
|
# @param row_index [Integer]
|
|
@@ -109,7 +150,7 @@ module Xlsxrb
|
|
|
109
150
|
def self.complement_runs: (untyped excluded, Integer min, Integer max) -> Array[[ Integer, Integer ]]
|
|
110
151
|
|
|
111
152
|
# Builds an A1-style reference from a column interval [col_start, col_end] (0-based)
|
|
112
|
-
# and a row interval [row_start, row_end] (
|
|
153
|
+
# and a row interval [row_start, row_end] (0-based row index).
|
|
113
154
|
#
|
|
114
155
|
# @param col_run [Array(Integer, Integer)]
|
|
115
156
|
# @param row_run [Array(Integer, Integer)]
|
|
@@ -124,9 +165,20 @@ module Xlsxrb
|
|
|
124
165
|
# @param row_runs [Array<Array(Integer, Integer)>]
|
|
125
166
|
# @param max_per_validation [Integer]
|
|
126
167
|
# @return [Array<String>]
|
|
168
|
+
# @raise [ArgumentError] if a run falls outside the Excel grid.
|
|
127
169
|
# : (Array[Array[Integer]] col_runs, Array[Array[Integer]] row_runs, ?Integer max_per_validation) -> Array[String]
|
|
128
170
|
def self.chunked_sqrefs: (Array[Array[Integer]] col_runs, Array[Array[Integer]] row_runs, ?Integer max_per_validation) -> Array[String]
|
|
129
171
|
|
|
172
|
+
# Raises if any [start, finish] run lies outside 0...limit.
|
|
173
|
+
#
|
|
174
|
+
# @param runs [Array<Array(Integer, Integer)>]
|
|
175
|
+
# @param limit [Integer] Number of valid indices (e.g. MAX_ROW).
|
|
176
|
+
# @param label [String] Capitalized axis name for the error message.
|
|
177
|
+
# @param plural [String] Plural axis name for the error message.
|
|
178
|
+
# @return [void]
|
|
179
|
+
# : (Array[Array[Integer]] runs, Integer limit, String label, String plural) -> void
|
|
180
|
+
def self.validate_runs!: (Array[Array[Integer]] runs, Integer limit, String label, String plural) -> void
|
|
181
|
+
|
|
130
182
|
# Quotes a sheet name for use in formula and defined name references, escaping single quotes with double single quotes.
|
|
131
183
|
#
|
|
132
184
|
# @param sheet_name [String, Object]
|
|
@@ -151,8 +203,24 @@ module Xlsxrb
|
|
|
151
203
|
# @param rows [Integer, Range, nil]
|
|
152
204
|
# @param range [String, nil]
|
|
153
205
|
# @return [String]
|
|
154
|
-
# : (?untyped value, ?sheet: untyped, ?
|
|
155
|
-
def self.normalize_defined_name_value: (?untyped value, ?sheet: untyped, ?
|
|
206
|
+
# : (?untyped value, ?sheet: untyped, ?columns: untyped, ?rows: untyped, ?range: untyped) -> String
|
|
207
|
+
def self.normalize_defined_name_value: (?untyped value, ?sheet: untyped, ?columns: untyped, ?rows: untyped, ?range: untyped) -> String
|
|
208
|
+
|
|
209
|
+
# Normalizes print titles repeating row specification to an Excel range string (e.g. "1:2").
|
|
210
|
+
# Accepts 0-based Integer, 0-based Range, or 1-based Excel range string.
|
|
211
|
+
#
|
|
212
|
+
# @param rows [Integer, Range, String, nil]
|
|
213
|
+
# @return [String, nil]
|
|
214
|
+
# : (untyped rows) -> String?
|
|
215
|
+
def self.normalize_print_titles_rows: (untyped rows) -> String?
|
|
216
|
+
|
|
217
|
+
# Normalizes print titles repeating column specification to an Excel range string (e.g. "A:B").
|
|
218
|
+
# Accepts 0-based Integer, Symbol, Range, or Excel column range string.
|
|
219
|
+
#
|
|
220
|
+
# @param columns [Integer, Symbol, Range, String, nil]
|
|
221
|
+
# @return [String, nil]
|
|
222
|
+
# : (untyped columns) -> String?
|
|
223
|
+
def self.normalize_print_titles_columns: (untyped columns) -> String?
|
|
156
224
|
|
|
157
225
|
# Normalizes data validation arguments (sqref, coordinate targeting, list arrays, input/error message inference).
|
|
158
226
|
#
|
|
@@ -201,7 +269,5 @@ module Xlsxrb
|
|
|
201
269
|
# @return [String] Excel-compliant worksheet name.
|
|
202
270
|
# : (untyped name, ?replace_char: String) -> String
|
|
203
271
|
def self.sanitize_sheet_name: (untyped name, ?replace_char: String) -> String
|
|
204
|
-
|
|
205
|
-
alias self.sheet_name self.sanitize_sheet_name
|
|
206
272
|
end
|
|
207
273
|
end
|
|
@@ -14,51 +14,75 @@ module Xlsxrb
|
|
|
14
14
|
#
|
|
15
15
|
# @api public
|
|
16
16
|
class Cell
|
|
17
|
+
# : Integer
|
|
17
18
|
attr_reader row_index: untyped
|
|
18
19
|
|
|
20
|
+
# : Integer
|
|
19
21
|
attr_reader column_index: untyped
|
|
20
22
|
|
|
23
|
+
# : untyped
|
|
21
24
|
attr_reader value: untyped
|
|
22
25
|
|
|
26
|
+
# : Elements::Formula?
|
|
23
27
|
attr_reader formula: untyped
|
|
24
28
|
|
|
29
|
+
# : (String | Symbol | Hash[Symbol, untyped])?
|
|
30
|
+
attr_reader style: untyped
|
|
31
|
+
|
|
32
|
+
# : Integer?
|
|
25
33
|
attr_reader style_index: untyped
|
|
26
34
|
|
|
35
|
+
# : Hash[untyped, untyped]
|
|
27
36
|
attr_reader unmapped_data: untyped
|
|
28
37
|
|
|
38
|
+
# : Array[String]
|
|
29
39
|
attr_reader errors: untyped
|
|
30
40
|
|
|
41
|
+
# : Elements::Hyperlink?
|
|
31
42
|
attr_reader hyperlink: untyped
|
|
32
43
|
|
|
44
|
+
# : Elements::Comment?
|
|
33
45
|
attr_reader comment: untyped
|
|
34
46
|
|
|
47
|
+
# : String?
|
|
35
48
|
attr_reader raw_value: untyped
|
|
36
49
|
|
|
50
|
+
# : String?
|
|
37
51
|
attr_reader format_code: untyped
|
|
38
52
|
|
|
39
|
-
|
|
40
|
-
|
|
53
|
+
# : Array[Elements::ThreadedComment]
|
|
41
54
|
attr_reader threaded_comments: untyped
|
|
42
55
|
|
|
43
56
|
# @param row_index [Integer] 0-based row index.
|
|
44
57
|
# @param column_index [Integer] 0-based column index.
|
|
45
58
|
# @param value [Object, nil] The cell's value.
|
|
46
59
|
# @param formula [Elements::Formula, nil] Optional formula.
|
|
47
|
-
# @param
|
|
60
|
+
# @param style [String, Symbol, Hash, nil] Style name or inline style properties.
|
|
61
|
+
# @param style_index [Integer, nil] 0-based style index.
|
|
48
62
|
# @param unmapped_data [Hash] Additional metadata.
|
|
49
63
|
# @param errors [Array<String>, nil] Validation errors.
|
|
50
|
-
# @param hyperlink [Hash, String,
|
|
51
|
-
# @param comment [Hash, String, nil] Optional cell comment or note.
|
|
64
|
+
# @param hyperlink [Elements::Hyperlink, Hash, String, nil] Optional hyperlink metadata or URL.
|
|
65
|
+
# @param comment [Elements::Comment, Hash, String, nil] Optional cell comment or note.
|
|
52
66
|
# @param raw_value [String, nil] Optional unparsed raw string value.
|
|
53
67
|
# @param format_code [String, nil] Optional OpenXML number/date format code.
|
|
54
68
|
# @param date1904 [Boolean] Whether the cell belongs to a 1904 date system workbook.
|
|
55
|
-
# @param threaded_comments [Array<Hash>, nil] Optional threaded comments.
|
|
56
|
-
# : (row_index: untyped, column_index: untyped, ?value: untyped, ?formula: (Elements::Formula | String)?, ?
|
|
57
|
-
def initialize: (row_index: untyped, column_index: untyped, ?value: untyped, ?formula: (Elements::Formula | String)?, ?
|
|
69
|
+
# @param threaded_comments [Array<Elements::ThreadedComment, Hash>, nil] Optional threaded comments.
|
|
70
|
+
# : (row_index: untyped, column_index: untyped, ?value: untyped, ?formula: (Elements::Formula | String | Hash[Symbol, untyped])?, ?style: (String | Symbol | Hash[Symbol, untyped])?, ?style_index: Integer?, ?unmapped_data: Hash[untyped, untyped], ?errors: Array[String]?, ?hyperlink: (Elements::Hyperlink | Hash[Symbol, untyped] | String)?, ?comment: (Elements::Comment | Hash[Symbol, untyped] | String)?, ?raw_value: String?, ?format_code: String?, ?date1904: bool, ?threaded_comments: Array[Elements::ThreadedComment | Hash[Symbol, untyped]]?) -> void
|
|
71
|
+
def initialize: (row_index: untyped, column_index: untyped, ?value: untyped, ?formula: (Elements::Formula | String | Hash[Symbol, untyped])?, ?style: (String | Symbol | Hash[Symbol, untyped])?, ?style_index: Integer?, ?unmapped_data: Hash[untyped, untyped], ?errors: Array[String]?, ?hyperlink: (Elements::Hyperlink | Hash[Symbol, untyped] | String)?, ?comment: (Elements::Comment | Hash[Symbol, untyped] | String)?, ?raw_value: String?, ?format_code: String?, ?date1904: bool, ?threaded_comments: Array[Elements::ThreadedComment | Hash[Symbol, untyped]]?) -> void
|
|
58
72
|
|
|
73
|
+
# @api private
|
|
59
74
|
# rubocop:disable Style/OptionalBooleanParameter
|
|
60
75
|
def self.fast_create: (untyped row_index, untyped column_index, untyped value, ?untyped style_index, ?untyped formula, ?untyped raw_value, ?untyped format_code, ?untyped date1904) -> untyped
|
|
61
76
|
|
|
77
|
+
# Assigns instance variables directly, in the same order as #initialize, for
|
|
78
|
+
# fast_create. One method call instead of one instance_variable_set per variable.
|
|
79
|
+
# : (untyped row_index, untyped column_index, untyped value, untyped style_index, untyped formula, String? raw_value, String? format_code, bool date1904) -> Cell
|
|
80
|
+
def init_fast: (untyped row_index, untyped column_index, untyped value, untyped style_index, untyped formula, String? raw_value, String? format_code, bool date1904) -> Cell
|
|
81
|
+
|
|
82
|
+
# @api private
|
|
83
|
+
# : (untyped formula) -> Elements::Formula?
|
|
84
|
+
def self.normalize_formula: (untyped formula) -> Elements::Formula?
|
|
85
|
+
|
|
62
86
|
def ==: (untyped other) -> untyped
|
|
63
87
|
|
|
64
88
|
alias eql? ==
|
|
@@ -67,7 +91,13 @@ module Xlsxrb
|
|
|
67
91
|
|
|
68
92
|
def deconstruct: () -> untyped
|
|
69
93
|
|
|
70
|
-
|
|
94
|
+
# Deconstructs cell attributes for pattern matching.
|
|
95
|
+
#
|
|
96
|
+
# @param _keys [Array<Symbol>, nil]
|
|
97
|
+
# @return [Hash{Symbol => Object}]
|
|
98
|
+
# @api public
|
|
99
|
+
# : (Array[Symbol]? _keys) -> Hash[Symbol, untyped]
|
|
100
|
+
def deconstruct_keys: (Array[Symbol]? _keys) -> Hash[Symbol, untyped]
|
|
71
101
|
|
|
72
102
|
def with: (**untyped changes) -> untyped
|
|
73
103
|
|
|
@@ -103,9 +133,7 @@ module Xlsxrb
|
|
|
103
133
|
# @return [Boolean]
|
|
104
134
|
# @api public
|
|
105
135
|
# : () -> bool
|
|
106
|
-
def
|
|
107
|
-
|
|
108
|
-
alias hyperlink? link?
|
|
136
|
+
def hyperlink?: () -> bool
|
|
109
137
|
|
|
110
138
|
# Returns the hyperlink target URL or location string, or nil.
|
|
111
139
|
#
|
|
@@ -140,14 +168,14 @@ module Xlsxrb
|
|
|
140
168
|
# @return [Boolean]
|
|
141
169
|
# @api public
|
|
142
170
|
# : () -> bool
|
|
143
|
-
def
|
|
171
|
+
def threaded_comment?: () -> bool
|
|
144
172
|
|
|
145
173
|
# Returns the root threaded comment for this cell, or nil.
|
|
146
174
|
#
|
|
147
|
-
# @return [
|
|
175
|
+
# @return [Elements::ThreadedComment, nil]
|
|
148
176
|
# @api public
|
|
149
|
-
# : () ->
|
|
150
|
-
def threaded_comment: () ->
|
|
177
|
+
# : () -> Elements::ThreadedComment?
|
|
178
|
+
def threaded_comment: () -> Elements::ThreadedComment?
|
|
151
179
|
|
|
152
180
|
# Returns the formatted string representation of the cell value according to its format code.
|
|
153
181
|
#
|
|
@@ -157,14 +185,6 @@ module Xlsxrb
|
|
|
157
185
|
# : (?String? custom_format_code) -> String?
|
|
158
186
|
def formatted_value: (?String? custom_format_code) -> String?
|
|
159
187
|
|
|
160
|
-
# Access cell attributes by Symbol key.
|
|
161
|
-
#
|
|
162
|
-
# @param key [Symbol] Attribute key (:value, :formula, :style_index, :ref, :column_index, :row_index, :type, :raw_value, :format_code, :formatted_value).
|
|
163
|
-
# @return [Object, nil]
|
|
164
|
-
# @api public
|
|
165
|
-
# : (Symbol key) -> untyped
|
|
166
|
-
def []: (Symbol key) -> untyped
|
|
167
|
-
|
|
168
188
|
# Returns the classified format category for this cell (:date, :datetime, :time, :number, :text, :general, or nil).
|
|
169
189
|
#
|
|
170
190
|
# @return [Symbol, nil]
|
|
@@ -172,6 +192,13 @@ module Xlsxrb
|
|
|
172
192
|
# : () -> Symbol?
|
|
173
193
|
def format_type: () -> Symbol?
|
|
174
194
|
|
|
195
|
+
# Returns the number format code for this cell.
|
|
196
|
+
#
|
|
197
|
+
# @return [String, nil]
|
|
198
|
+
# @api public
|
|
199
|
+
# : () -> String?
|
|
200
|
+
def number_format: () -> String?
|
|
201
|
+
|
|
175
202
|
# Returns whether the cell has a date, datetime, or time format.
|
|
176
203
|
#
|
|
177
204
|
# @return [Boolean]
|
|
@@ -179,6 +206,20 @@ module Xlsxrb
|
|
|
179
206
|
# : () -> bool
|
|
180
207
|
def date_format?: () -> bool
|
|
181
208
|
|
|
209
|
+
# Returns whether the cell has a datetime format (date with time).
|
|
210
|
+
#
|
|
211
|
+
# @return [Boolean]
|
|
212
|
+
# @api public
|
|
213
|
+
# : () -> bool
|
|
214
|
+
def datetime_format?: () -> bool
|
|
215
|
+
|
|
216
|
+
# Returns whether the cell has a date-only format.
|
|
217
|
+
#
|
|
218
|
+
# @return [Boolean]
|
|
219
|
+
# @api public
|
|
220
|
+
# : () -> bool
|
|
221
|
+
def date_only_format?: () -> bool
|
|
222
|
+
|
|
182
223
|
# Returns whether the cell has a time-only format.
|
|
183
224
|
#
|
|
184
225
|
# @return [Boolean]
|
|
@@ -193,13 +234,6 @@ module Xlsxrb
|
|
|
193
234
|
# : () -> bool
|
|
194
235
|
def date1904?: () -> bool
|
|
195
236
|
|
|
196
|
-
# Returns the cell value.
|
|
197
|
-
#
|
|
198
|
-
# @return [Object, nil]
|
|
199
|
-
# @api public
|
|
200
|
-
# : () -> untyped
|
|
201
|
-
def content: () -> untyped
|
|
202
|
-
|
|
203
237
|
# Returns the string representation of the cell value.
|
|
204
238
|
#
|
|
205
239
|
# @return [String]
|
|
@@ -223,69 +257,42 @@ module Xlsxrb
|
|
|
223
257
|
|
|
224
258
|
# Converts the cell value (numeric serial date or date string) to Date.
|
|
225
259
|
#
|
|
226
|
-
# @param date1904 [Boolean, nil] Whether to use the 1904 date system (defaults to cell's date1904 setting).
|
|
227
260
|
# @return [Date, nil]
|
|
228
261
|
# @api public
|
|
229
|
-
# : (
|
|
230
|
-
def to_date: (
|
|
262
|
+
# : () -> Date?
|
|
263
|
+
def to_date: () -> Date?
|
|
231
264
|
|
|
232
265
|
# Converts the cell value (numeric serial datetime or datetime string) to Time.
|
|
233
266
|
#
|
|
234
|
-
# @param date1904 [Boolean, nil] Whether to use the 1904 date system (defaults to cell's date1904 setting).
|
|
235
267
|
# @return [Time, nil]
|
|
236
268
|
# @api public
|
|
237
|
-
# : (
|
|
238
|
-
def to_time: (
|
|
269
|
+
# : () -> Time?
|
|
270
|
+
def to_time: () -> Time?
|
|
239
271
|
|
|
240
272
|
# Pure calculation: converts a 0-based column index to an Excel letter.
|
|
241
273
|
#
|
|
242
274
|
# @param index [Integer] 0-based column index.
|
|
243
275
|
# @return [String] Excel column letter.
|
|
276
|
+
# @api private
|
|
244
277
|
# : (Integer index) -> String
|
|
245
278
|
def self.calculate_column_letter: (Integer index) -> String
|
|
246
279
|
|
|
247
|
-
#
|
|
248
|
-
|
|
249
|
-
# @example
|
|
250
|
-
# Cell.column_letter(0) #=> "A"
|
|
251
|
-
# Cell.column_letter(26) #=> "AA"
|
|
252
|
-
#
|
|
253
|
-
# @param index [Integer] 0-based column index.
|
|
254
|
-
# @return [String] Excel column letter.
|
|
255
|
-
# @api public
|
|
256
|
-
# : (untyped index) -> String
|
|
257
|
-
def self.column_letter: (untyped index) -> String
|
|
280
|
+
# @api private
|
|
281
|
+
def self._column_letter: (untyped index) -> untyped
|
|
258
282
|
|
|
259
283
|
# Pure calculation: converts an uppercase column letter string to a 0-based index.
|
|
260
284
|
#
|
|
261
285
|
# @param letter [String] Uppercase column letter string (e.g. "A", "AA").
|
|
262
286
|
# @return [Integer] 0-based column index.
|
|
287
|
+
# @api private
|
|
263
288
|
# : (String letter) -> Integer
|
|
264
289
|
def self.calculate_column_index: (String letter) -> Integer
|
|
265
290
|
|
|
266
|
-
#
|
|
267
|
-
|
|
268
|
-
# @example
|
|
269
|
-
# Cell.column_index("A") #=> 0
|
|
270
|
-
# Cell.column_index(:AA) #=> 26
|
|
271
|
-
#
|
|
272
|
-
# @param letter [String, Symbol, Integer] Column letter or integer index.
|
|
273
|
-
# @return [Integer] 0-based column index.
|
|
274
|
-
# @api public
|
|
275
|
-
# : (String | Symbol | Integer letter) -> Integer
|
|
276
|
-
def self.column_index: (String | Symbol | Integer letter) -> Integer
|
|
291
|
+
# @api private
|
|
292
|
+
def self._column_index: (untyped letter) -> untyped
|
|
277
293
|
|
|
278
|
-
#
|
|
279
|
-
|
|
280
|
-
# @example
|
|
281
|
-
# Cell.parse_ref("A1") #=> [0, 0]
|
|
282
|
-
# Cell.parse_ref("C10") #=> [9, 2]
|
|
283
|
-
#
|
|
284
|
-
# @param ref [String, nil] Excel cell reference.
|
|
285
|
-
# @return [Array(Integer, Integer), nil] 0-based [row_index, col_index].
|
|
286
|
-
# @api public
|
|
287
|
-
# : (String? ref) -> [Integer, Integer]?
|
|
288
|
-
def self.parse_ref: (String? ref) -> [ Integer, Integer ]?
|
|
294
|
+
# @api private
|
|
295
|
+
def self._parse_ref: (untyped ref) -> untyped
|
|
289
296
|
|
|
290
297
|
# Returns whether the coordinates are within OOXML limits (row: 0..1,048,575, col: 0..16,383).
|
|
291
298
|
#
|
|
@@ -308,6 +315,7 @@ module Xlsxrb
|
|
|
308
315
|
# @param column_index [Integer]
|
|
309
316
|
# @param value [Object]
|
|
310
317
|
# @return [Array<String>] List of errors.
|
|
318
|
+
# @api private
|
|
311
319
|
# : (untyped row_index, untyped column_index, untyped value) -> Array[String]
|
|
312
320
|
def self.validate: (untyped row_index, untyped column_index, untyped value) -> Array[String]
|
|
313
321
|
end
|
|
@@ -11,7 +11,6 @@ module Xlsxrb
|
|
|
11
11
|
# @api public
|
|
12
12
|
# rubocop:disable Style/DataInheritance -- Required as class syntax for mutant subject matcher
|
|
13
13
|
class Column
|
|
14
|
-
# rubocop:enable Style/DataInheritance
|
|
15
14
|
# @param index [Integer] 0-based column index.
|
|
16
15
|
# @param width [Float, Integer, nil] Column width in characters.
|
|
17
16
|
# @param hidden [Boolean] Whether the column is hidden.
|
|
@@ -20,8 +19,10 @@ module Xlsxrb
|
|
|
20
19
|
# @param style_index [Integer, String, Symbol, Hash, nil] Optional style identifier or inline style.
|
|
21
20
|
# @param unmapped_data [Hash] Additional metadata.
|
|
22
21
|
# @param errors [Array<String>, nil] Validation errors.
|
|
23
|
-
#
|
|
24
|
-
|
|
22
|
+
# @param best_fit [Boolean] Whether the column automatically fits content.
|
|
23
|
+
# @param collapsed [Boolean] Whether the column is collapsed.
|
|
24
|
+
# : (index: Integer, ?width: Float | Integer | nil, ?hidden: bool, ?custom_width: bool, ?outline_level: Integer | nil, ?style_index: (Integer | String | Symbol | Hash[Symbol, untyped])?, ?unmapped_data: Hash[untyped, untyped], ?errors: Array[String]?, ?best_fit: bool, ?collapsed: bool) -> void
|
|
25
|
+
def initialize: (index: Integer, ?width: Float | Integer | nil, ?hidden: bool, ?custom_width: bool, ?outline_level: Integer | nil, ?style_index: (Integer | String | Symbol | Hash[Symbol, untyped])?, ?unmapped_data: Hash[untyped, untyped], ?errors: Array[String]?, ?best_fit: bool, ?collapsed: bool) -> void
|
|
25
26
|
|
|
26
27
|
# Returns whether the column definition is valid according to OOXML specifications.
|
|
27
28
|
#
|
|
@@ -29,6 +30,56 @@ module Xlsxrb
|
|
|
29
30
|
# : () -> bool
|
|
30
31
|
def valid?: () -> bool
|
|
31
32
|
|
|
33
|
+
# Returns whether the column is hidden.
|
|
34
|
+
#
|
|
35
|
+
# @return [Boolean]
|
|
36
|
+
# @api public
|
|
37
|
+
# : () -> bool
|
|
38
|
+
def hidden?: () -> bool
|
|
39
|
+
|
|
40
|
+
# Returns whether custom width is set.
|
|
41
|
+
#
|
|
42
|
+
# @return [Boolean]
|
|
43
|
+
# @api public
|
|
44
|
+
# : () -> bool
|
|
45
|
+
def custom_width?: () -> bool
|
|
46
|
+
|
|
47
|
+
# Returns whether best fit is enabled.
|
|
48
|
+
#
|
|
49
|
+
# @return [Boolean]
|
|
50
|
+
# @api public
|
|
51
|
+
# : () -> bool
|
|
52
|
+
def best_fit?: () -> bool
|
|
53
|
+
|
|
54
|
+
# Returns whether the column is collapsed.
|
|
55
|
+
#
|
|
56
|
+
# @return [Boolean]
|
|
57
|
+
# @api public
|
|
58
|
+
# : () -> bool
|
|
59
|
+
def collapsed?: () -> bool
|
|
60
|
+
|
|
61
|
+
# Deconstructs column attributes for pattern matching.
|
|
62
|
+
#
|
|
63
|
+
# @param _keys [Array<Symbol>, nil]
|
|
64
|
+
# @return [Hash{Symbol => Object}]
|
|
65
|
+
# @api public
|
|
66
|
+
# : (Array[Symbol]? _keys) -> Hash[Symbol, untyped]
|
|
67
|
+
def deconstruct_keys: (Array[Symbol]? _keys) -> Hash[Symbol, untyped]
|
|
68
|
+
|
|
69
|
+
# Returns the column letter (e.g. "A", "B", "AA").
|
|
70
|
+
#
|
|
71
|
+
# @return [String]
|
|
72
|
+
# @api public
|
|
73
|
+
# : () -> String
|
|
74
|
+
def column_letter: () -> String
|
|
75
|
+
|
|
76
|
+
# Returns the style identifier or inline style.
|
|
77
|
+
#
|
|
78
|
+
# @return [Integer, String, Symbol, Hash, nil]
|
|
79
|
+
# @api public
|
|
80
|
+
# : () -> (Integer | String | Symbol | Hash[Symbol, untyped])?
|
|
81
|
+
def style: () -> (Integer | String | Symbol | Hash[Symbol, untyped])?
|
|
82
|
+
|
|
32
83
|
# Returns whether the column index is within valid OOXML range (0..16383).
|
|
33
84
|
#
|
|
34
85
|
# @param index [Object]
|
|
@@ -40,6 +91,7 @@ module Xlsxrb
|
|
|
40
91
|
#
|
|
41
92
|
# @param index [Integer]
|
|
42
93
|
# @return [Array<String>] List of errors.
|
|
94
|
+
# @api private
|
|
43
95
|
# : (untyped index) -> Array[String]
|
|
44
96
|
def self.validate: (untyped index) -> Array[String]
|
|
45
97
|
end
|
|
@@ -9,12 +9,6 @@ module Xlsxrb
|
|
|
9
9
|
#
|
|
10
10
|
# @api public
|
|
11
11
|
module CoordinateAccess
|
|
12
|
-
# Returns a Hash mapping Excel cell references (e.g. "A1") to Cell objects.
|
|
13
|
-
#
|
|
14
|
-
# @return [Hash<String, Elements::Cell>]
|
|
15
|
-
# : () -> Hash[String, Elements::Cell]
|
|
16
|
-
def cells_hash: () -> Hash[String, Elements::Cell]
|
|
17
|
-
|
|
18
12
|
# Returns all cells ordered by row and column index.
|
|
19
13
|
#
|
|
20
14
|
# @return [Array<Elements::Cell>]
|
|
@@ -22,16 +16,21 @@ module Xlsxrb
|
|
|
22
16
|
# : () -> Array[Elements::Cell]
|
|
23
17
|
def cells: () -> Array[Elements::Cell]
|
|
24
18
|
|
|
25
|
-
# Access a cell by
|
|
19
|
+
# Access a cell by Excel-style reference (e.g. "A1") or 0-based coordinate indices (row, col).
|
|
26
20
|
#
|
|
27
|
-
# @example
|
|
21
|
+
# @example Coordinate string
|
|
28
22
|
# sheet["A1"] #=> #<Elements::Cell value="Hello">
|
|
29
23
|
#
|
|
30
|
-
# @
|
|
24
|
+
# @example Row and column indices (0-based)
|
|
25
|
+
# sheet[0, 0] #=> #<Elements::Cell value="Hello">
|
|
26
|
+
# sheet[0, "A"] #=> #<Elements::Cell value="Hello">
|
|
27
|
+
#
|
|
28
|
+
# @param ref_or_row [String, Symbol, Integer] Cell reference (e.g. "A1" or :A1) or 0-based row index.
|
|
29
|
+
# @param col [Integer, String, Symbol, nil] Optional 0-based column index or column letter.
|
|
31
30
|
# @return [Elements::Cell, nil]
|
|
32
31
|
# @api public
|
|
33
|
-
# : (String | Symbol
|
|
34
|
-
def []: (String | Symbol
|
|
32
|
+
# : (String | Symbol | Integer ref_or_row, ?Integer | String | Symbol | nil col) -> Elements::Cell?
|
|
33
|
+
def []: (String | Symbol | Integer ref_or_row, ?Integer | String | Symbol | nil col) -> Elements::Cell?
|
|
35
34
|
|
|
36
35
|
# Returns the row at the given 0-based index, or nil.
|
|
37
36
|
#
|
|
@@ -55,34 +54,41 @@ module Xlsxrb
|
|
|
55
54
|
# : () -> Elements::Row?
|
|
56
55
|
def last_row: () -> Elements::Row?
|
|
57
56
|
|
|
58
|
-
# Returns
|
|
57
|
+
# Returns 0-based bounds { min_row: r1, max_row: r2, min_column: c1, max_column: c2 } from dimension ref.
|
|
58
|
+
#
|
|
59
|
+
# @example
|
|
60
|
+
# sheet.dimension_bounds #=> { min_row: 0, max_row: 4, min_column: 0, max_column: 2 }
|
|
59
61
|
#
|
|
60
|
-
# @return [Integer, nil]
|
|
62
|
+
# @return [Hash{Symbol => Integer}, nil]
|
|
61
63
|
# @api public
|
|
62
|
-
# : () -> Integer?
|
|
63
|
-
def
|
|
64
|
+
# : () -> Hash[Symbol, Integer]?
|
|
65
|
+
def dimension_bounds: () -> Hash[Symbol, Integer]?
|
|
64
66
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
#
|
|
67
|
+
# Returns the 0-based range of rows containing data, or nil.
|
|
68
|
+
#
|
|
69
|
+
# @example
|
|
70
|
+
# sheet.row_range #=> 0..9
|
|
68
71
|
#
|
|
69
|
-
# @return [Integer
|
|
72
|
+
# @return [Range<Integer>, nil]
|
|
70
73
|
# @api public
|
|
71
|
-
# : () -> Integer?
|
|
72
|
-
def
|
|
73
|
-
|
|
74
|
-
alias last_col last_column
|
|
74
|
+
# : () -> Range[Integer]?
|
|
75
|
+
def row_range: () -> Range[Integer]?
|
|
75
76
|
|
|
76
|
-
# Returns the
|
|
77
|
+
# Returns the 0-based range of columns containing data, or nil.
|
|
77
78
|
#
|
|
78
79
|
# @example
|
|
79
|
-
# sheet.
|
|
80
|
+
# sheet.column_range #=> 0..4
|
|
80
81
|
#
|
|
81
|
-
# @
|
|
82
|
-
# @return [Object, nil]
|
|
82
|
+
# @return [Range<Integer>, nil]
|
|
83
83
|
# @api public
|
|
84
|
-
# : (
|
|
85
|
-
def
|
|
84
|
+
# : () -> Range[Integer]?
|
|
85
|
+
def column_range: () -> Range[Integer]?
|
|
86
|
+
|
|
87
|
+
private
|
|
88
|
+
|
|
89
|
+
# Returns a Hash mapping Excel cell references (e.g. "A1") to Cell objects.
|
|
90
|
+
# : () -> Hash[String, Elements::Cell]
|
|
91
|
+
def _cells_hash: () -> Hash[String, Elements::Cell]
|
|
86
92
|
end
|
|
87
93
|
end
|
|
88
94
|
end
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
module Xlsxrb
|
|
4
4
|
module Elements
|
|
5
5
|
# Represents an embedded image anchored to worksheet cells.
|
|
6
|
-
# Coordinates (from_row,
|
|
6
|
+
# Coordinates (from_row, from_column, to_row, to_column) are 0-based.
|
|
7
7
|
#
|
|
8
8
|
# @example Access image properties
|
|
9
9
|
# image = sheet.images.first
|
|
10
10
|
# image.filename #=> "image1.png"
|
|
11
|
-
# image.
|
|
11
|
+
# image.ref #=> "B3"
|
|
12
12
|
# image.content_type #=> "image/png"
|
|
13
13
|
# image.data #=> "\x89PNG..."
|
|
14
14
|
#
|
|
@@ -20,27 +20,23 @@ module Xlsxrb
|
|
|
20
20
|
# @param name [String, nil] Image or shape name.
|
|
21
21
|
# @param content_type [String, nil] MIME content type (e.g. "image/png").
|
|
22
22
|
# @param data [String, nil] Raw binary image data.
|
|
23
|
-
# @param
|
|
23
|
+
# @param from_column [Integer, nil] 0-based starting column index.
|
|
24
24
|
# @param from_row [Integer] 0-based starting row index.
|
|
25
|
-
# @param
|
|
25
|
+
# @param to_column [Integer, nil] 0-based ending column index (nil for 1-cell anchor).
|
|
26
26
|
# @param to_row [Integer, nil] 0-based ending row index (nil for 1-cell anchor).
|
|
27
27
|
# @param cx [Integer, nil] Extent width in EMUs (English Metric Units).
|
|
28
28
|
# @param cy [Integer, nil] Extent height in EMUs (English Metric Units).
|
|
29
29
|
# @param unmapped_data [Hash] Additional metadata from drawing XML.
|
|
30
|
-
# : (filename: String, ?name: String?, ?content_type: String?, ?data: String?, ?
|
|
30
|
+
# : (filename: String, ?name: String?, ?content_type: String?, ?data: String?, ?from_column: Integer?, ?from_row: Integer, ?to_column: Integer?, ?to_row: Integer?, ?cx: Integer?, ?cy: Integer?, ?unmapped_data: Hash[untyped, untyped]) -> void
|
|
31
31
|
# rubocop:disable Naming/MethodParameterName
|
|
32
|
-
def initialize: (filename: String, ?name: String?, ?content_type: String?, ?data: String?, ?
|
|
32
|
+
def initialize: (filename: String, ?name: String?, ?content_type: String?, ?data: String?, ?from_column: Integer?, ?from_row: Integer, ?to_column: Integer?, ?to_row: Integer?, ?cx: Integer?, ?cy: Integer?, ?unmapped_data: Hash[untyped, untyped]) -> void
|
|
33
33
|
|
|
34
34
|
# Returns the top-left cell coordinate reference string (e.g. "A1").
|
|
35
35
|
#
|
|
36
36
|
# @return [String]
|
|
37
37
|
# @api public
|
|
38
38
|
# : () -> String
|
|
39
|
-
def
|
|
40
|
-
|
|
41
|
-
alias cell cell_ref
|
|
42
|
-
|
|
43
|
-
alias ref cell_ref
|
|
39
|
+
def ref: () -> String
|
|
44
40
|
|
|
45
41
|
# Returns the bottom-right cell coordinate reference string (e.g. "B5"), or nil for 1-cell anchors.
|
|
46
42
|
#
|