xlsxrb 0.1.16 → 0.1.18
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 +157 -1
- data/README.md +81 -21
- data/lib/ruby_lsp/xlsxrb/completion_listener.rb +31 -61
- data/lib/xlsxrb/chart_builder.rb +619 -98
- data/lib/xlsxrb/dsl_helpers.rb +583 -15
- data/lib/xlsxrb/elements/cell.rb +265 -53
- data/lib/xlsxrb/elements/column.rb +95 -6
- data/lib/xlsxrb/elements/coordinate_access.rb +108 -10
- data/lib/xlsxrb/elements/image.rb +81 -15
- data/lib/xlsxrb/elements/metadata.rb +2733 -0
- data/lib/xlsxrb/elements/row.rb +130 -46
- data/lib/xlsxrb/elements/styles.rb +184 -76
- data/lib/xlsxrb/elements/types.rb +243 -7
- data/lib/xlsxrb/elements/workbook.rb +202 -65
- data/lib/xlsxrb/elements/worksheet.rb +728 -85
- data/lib/xlsxrb/elements.rb +1 -0
- data/lib/xlsxrb/ooxml/reader/listeners/core_listeners.rb +32 -3
- data/lib/xlsxrb/ooxml/reader/listeners/drawing_listeners.rb +194 -26
- data/lib/xlsxrb/ooxml/reader/listeners/feature_listeners.rb +372 -18
- data/lib/xlsxrb/ooxml/reader/listeners/style_listeners.rb +33 -14
- data/lib/xlsxrb/ooxml/reader.rb +92 -0
- data/lib/xlsxrb/ooxml/styles_parser.rb +29 -14
- data/lib/xlsxrb/ooxml/workbook_parser.rb +18 -3
- data/lib/xlsxrb/ooxml/workbook_writer.rb +351 -77
- data/lib/xlsxrb/ooxml/worksheet_parser.rb +18 -4
- data/lib/xlsxrb/ooxml/worksheet_writer.rb +349 -103
- data/lib/xlsxrb/ooxml/writer/drawing_xml.rb +584 -443
- data/lib/xlsxrb/ooxml/writer/features_xml.rb +52 -14
- data/lib/xlsxrb/ooxml/writer/styles_xml.rb +42 -18
- data/lib/xlsxrb/ooxml/writer.rb +288 -35
- data/lib/xlsxrb/ooxml/zip_generator.rb +2 -0
- data/lib/xlsxrb/ooxml/zip_reader.rb +47 -10
- data/lib/xlsxrb/ooxml/zip_writer.rb +15 -5
- data/lib/xlsxrb/stream_row.rb +97 -18
- data/lib/xlsxrb/stream_sheet.rb +827 -157
- data/lib/xlsxrb/stream_writer.rb +2766 -375
- data/lib/xlsxrb/style_builder.rb +821 -105
- data/lib/xlsxrb/utils.rb +82 -57
- data/lib/xlsxrb/version.rb +1 -1
- data/lib/xlsxrb/workbook_builder.rb +542 -62
- data/lib/xlsxrb/worksheet_builder.rb +2279 -209
- data/lib/xlsxrb.rb +1539 -344
- data/sig/generated/xlsxrb/chart_builder.rbs +336 -79
- data/sig/generated/xlsxrb/dsl_helpers.rbs +137 -4
- data/sig/generated/xlsxrb/elements/cell.rbs +104 -15
- data/sig/generated/xlsxrb/elements/column.rbs +62 -3
- data/sig/generated/xlsxrb/elements/coordinate_access.rbs +49 -7
- data/sig/generated/xlsxrb/elements/image.rbs +30 -8
- data/sig/generated/xlsxrb/elements/metadata.rbs +1587 -0
- data/sig/generated/xlsxrb/elements/row.rbs +61 -21
- data/sig/generated/xlsxrb/elements/styles.rbs +96 -58
- data/sig/generated/xlsxrb/elements/types.rbs +29 -0
- data/sig/generated/xlsxrb/elements/workbook.rbs +92 -44
- data/sig/generated/xlsxrb/elements/worksheet.rbs +259 -38
- data/sig/generated/xlsxrb/ooxml/reader/listeners/core_listeners.rbs +2 -0
- data/sig/generated/xlsxrb/ooxml/reader/listeners/drawing_listeners.rbs +74 -2
- data/sig/generated/xlsxrb/ooxml/reader/listeners/feature_listeners.rbs +97 -0
- data/sig/generated/xlsxrb/ooxml/reader/listeners/style_listeners.rbs +3 -0
- data/sig/generated/xlsxrb/ooxml/reader.rbs +20 -0
- data/sig/generated/xlsxrb/ooxml/styles_parser.rbs +3 -0
- data/sig/generated/xlsxrb/ooxml/workbook_parser.rbs +8 -0
- data/sig/generated/xlsxrb/ooxml/workbook_writer.rbs +8 -4
- data/sig/generated/xlsxrb/ooxml/worksheet_parser.rbs +1 -1
- data/sig/generated/xlsxrb/ooxml/worksheet_writer.rbs +12 -1
- data/sig/generated/xlsxrb/ooxml/writer/drawing_xml.rbs +16 -0
- data/sig/generated/xlsxrb/ooxml/writer.rbs +45 -8
- data/sig/generated/xlsxrb/ooxml/zip_generator.rbs +2 -0
- data/sig/generated/xlsxrb/ooxml/zip_reader.rbs +2 -2
- data/sig/generated/xlsxrb/ooxml/zip_writer.rbs +8 -2
- data/sig/generated/xlsxrb/stream_row.rbs +48 -14
- data/sig/generated/xlsxrb/stream_sheet.rbs +398 -89
- data/sig/generated/xlsxrb/stream_writer.rbs +1601 -219
- data/sig/generated/xlsxrb/style_builder.rbs +403 -75
- data/sig/generated/xlsxrb/utils.rbs +49 -13
- data/sig/generated/xlsxrb/workbook_builder.rbs +308 -26
- data/sig/generated/xlsxrb/worksheet_builder.rbs +1142 -96
- data/sig/generated/xlsxrb.rbs +321 -52
- metadata +3 -1
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
module Xlsxrb
|
|
4
4
|
# Public coordinate conversion and reference parsing utilities.
|
|
5
5
|
#
|
|
6
|
+
# @deprecated Use top-level {Xlsxrb} coordinate and date helpers instead.
|
|
6
7
|
# @api public
|
|
7
8
|
module Utils
|
|
8
9
|
# Converts a cell reference string (e.g. "A1", "BC100") to 0-based [row, col] coordinates.
|
|
@@ -11,9 +12,9 @@ module Xlsxrb
|
|
|
11
12
|
# Xlsxrb::Utils.ref_to_row_col("A1") #=> [0, 0]
|
|
12
13
|
# Xlsxrb::Utils.ref_to_row_col("BC100") #=> [99, 54]
|
|
13
14
|
#
|
|
15
|
+
# @deprecated Use {Xlsxrb.parse_ref} instead. Will be removed in 0.2.0.
|
|
14
16
|
# @param cell_ref [String, nil] Excel cell reference string.
|
|
15
17
|
# @return [Array(Integer, Integer), nil] 0-based [row_idx, col_idx] tuple, or nil if invalid.
|
|
16
|
-
# @api public
|
|
17
18
|
# : (String? cell_ref) -> [Integer, Integer]?
|
|
18
19
|
def self.ref_to_row_col: (String? cell_ref) -> [ Integer, Integer ]?
|
|
19
20
|
|
|
@@ -23,10 +24,10 @@ module Xlsxrb
|
|
|
23
24
|
# Xlsxrb::Utils.row_col_to_ref(0, 0) #=> "A1"
|
|
24
25
|
# Xlsxrb::Utils.row_col_to_ref(99, 54) #=> "BC100"
|
|
25
26
|
#
|
|
27
|
+
# @deprecated Use {Xlsxrb.cell_to_ref} instead. Will be removed in 0.2.0.
|
|
26
28
|
# @param row_idx [Integer] 0-based row index.
|
|
27
29
|
# @param col_idx [Integer] 0-based column index.
|
|
28
30
|
# @return [String] A1-style reference string.
|
|
29
|
-
# @api public
|
|
30
31
|
# : (Integer row_idx, Integer col_idx) -> String
|
|
31
32
|
def self.row_col_to_ref: (Integer row_idx, Integer col_idx) -> String
|
|
32
33
|
|
|
@@ -39,9 +40,9 @@ module Xlsxrb
|
|
|
39
40
|
# @example Single cell reference
|
|
40
41
|
# Xlsxrb::Utils.parse_range("B5") #=> [[4, 1], [4, 1]]
|
|
41
42
|
#
|
|
43
|
+
# @deprecated Use {Xlsxrb.parse_range} instead. Will be removed in 0.2.0.
|
|
42
44
|
# @param range_ref [String, nil] Cell range reference string.
|
|
43
45
|
# @return [Array([Integer, Integer], [Integer, Integer]), nil] 0-based coordinate pairs, or nil if invalid.
|
|
44
|
-
# @api public
|
|
45
46
|
# : (String? range_ref) -> [[Integer, Integer], [Integer, Integer]]?
|
|
46
47
|
def self.parse_range: (String? range_ref) -> [ [ Integer, Integer ], [ Integer, Integer ] ]?
|
|
47
48
|
|
|
@@ -53,12 +54,12 @@ module Xlsxrb
|
|
|
53
54
|
# @example Single cell coordinates
|
|
54
55
|
# Xlsxrb::Utils.range_to_ref(4, 1, 4, 1) #=> "B5"
|
|
55
56
|
#
|
|
57
|
+
# @deprecated Use {Xlsxrb.range_to_ref} instead. Will be removed in 0.2.0.
|
|
56
58
|
# @param top_row [Integer] 0-based start row index.
|
|
57
59
|
# @param left_col [Integer] 0-based start column index.
|
|
58
60
|
# @param bottom_row [Integer] 0-based end row index.
|
|
59
61
|
# @param right_col [Integer] 0-based end column index.
|
|
60
62
|
# @return [String] A1-style range reference string.
|
|
61
|
-
# @api public
|
|
62
63
|
# : (Integer top_row, Integer left_col, Integer bottom_row, Integer right_col) -> String
|
|
63
64
|
def self.range_to_ref: (Integer top_row, Integer left_col, Integer bottom_row, Integer right_col) -> String
|
|
64
65
|
|
|
@@ -68,9 +69,9 @@ module Xlsxrb
|
|
|
68
69
|
# Xlsxrb::Utils.col_name_to_index("A") #=> 0
|
|
69
70
|
# Xlsxrb::Utils.col_name_to_index("BC") #=> 54
|
|
70
71
|
#
|
|
72
|
+
# @deprecated Use {Xlsxrb.column_index} instead. Will be removed in 0.2.0.
|
|
71
73
|
# @param col_name [String, Symbol, Integer] Column letter or index.
|
|
72
74
|
# @return [Integer] 0-based column index.
|
|
73
|
-
# @api public
|
|
74
75
|
# : (String | Symbol | Integer col_name) -> Integer
|
|
75
76
|
def self.col_name_to_index: (String | Symbol | Integer col_name) -> Integer
|
|
76
77
|
|
|
@@ -80,9 +81,9 @@ module Xlsxrb
|
|
|
80
81
|
# Xlsxrb::Utils.col_index_to_name(0) #=> "A"
|
|
81
82
|
# Xlsxrb::Utils.col_index_to_name(54) #=> "BC"
|
|
82
83
|
#
|
|
84
|
+
# @deprecated Use {Xlsxrb.column_letter} instead. Will be removed in 0.2.0.
|
|
83
85
|
# @param col_idx [Integer] 0-based column index.
|
|
84
86
|
# @return [String] Column letter name.
|
|
85
|
-
# @api public
|
|
86
87
|
# : (Integer col_idx) -> String
|
|
87
88
|
def self.col_index_to_name: (Integer col_idx) -> String
|
|
88
89
|
|
|
@@ -92,9 +93,9 @@ module Xlsxrb
|
|
|
92
93
|
# Xlsxrb::Utils.split_coordinate("A1") #=> ["A", 1]
|
|
93
94
|
# Xlsxrb::Utils.split_coordinate("BC100") #=> ["BC", 100]
|
|
94
95
|
#
|
|
96
|
+
# @deprecated Use {Xlsxrb.split_coordinate} instead. Will be removed in 0.2.0.
|
|
95
97
|
# @param cell_ref [String, nil] Excel cell reference string.
|
|
96
98
|
# @return [Array(String, Integer), nil] [col_name, row_number] tuple (1-based row), or nil if invalid.
|
|
97
|
-
# @api public
|
|
98
99
|
# : (String? cell_ref) -> [String, Integer]?
|
|
99
100
|
def self.split_coordinate: (String? cell_ref) -> [ String, Integer ]?
|
|
100
101
|
|
|
@@ -103,10 +104,10 @@ module Xlsxrb
|
|
|
103
104
|
# @example
|
|
104
105
|
# Xlsxrb::Utils.date_to_serial(Date.new(2026, 1, 1)) #=> 46023
|
|
105
106
|
#
|
|
107
|
+
# @deprecated Use {Xlsxrb.date_to_serial} instead. Will be removed in 0.2.0.
|
|
106
108
|
# @param date_or_time [Date, Time] Date or Time instance.
|
|
107
109
|
# @param date1904 [Boolean] Whether to use the 1904 date system.
|
|
108
110
|
# @return [Integer, Float] Serial number.
|
|
109
|
-
# @api public
|
|
110
111
|
# : (Date | Time date_or_time, ?date1904: bool) -> (Integer | Float)
|
|
111
112
|
def self.date_to_serial: (Date | Time date_or_time, ?date1904: bool) -> (Integer | Float)
|
|
112
113
|
|
|
@@ -116,10 +117,10 @@ module Xlsxrb
|
|
|
116
117
|
# Xlsxrb::Utils.valid_excel_date?(46023) #=> true
|
|
117
118
|
# Xlsxrb::Utils.valid_excel_date?(-1) #=> false
|
|
118
119
|
#
|
|
120
|
+
# @deprecated Use {Xlsxrb.valid_excel_date?} instead. Will be removed in 0.2.0.
|
|
119
121
|
# @param serial [Object] Serial number candidate.
|
|
120
122
|
# @param date1904 [Boolean] Whether to use the 1904 date system.
|
|
121
123
|
# @return [Boolean]
|
|
122
|
-
# @api public
|
|
123
124
|
# : (untyped serial, ?date1904: bool) -> bool
|
|
124
125
|
def self.valid_excel_date?: (untyped serial, ?date1904: bool) -> bool
|
|
125
126
|
|
|
@@ -128,10 +129,10 @@ module Xlsxrb
|
|
|
128
129
|
# @example
|
|
129
130
|
# Xlsxrb::Utils.serial_to_date(46023) #=> #<Date: 2026-01-01>
|
|
130
131
|
#
|
|
132
|
+
# @deprecated Use {Xlsxrb.serial_to_date} instead. Will be removed in 0.2.0.
|
|
131
133
|
# @param serial [Numeric] Excel serial number.
|
|
132
134
|
# @param date1904 [Boolean] Whether to use the 1904 date system.
|
|
133
135
|
# @return [Date]
|
|
134
|
-
# @api public
|
|
135
136
|
# : (Numeric serial, ?date1904: bool) -> Date
|
|
136
137
|
def self.serial_to_date: (Numeric serial, ?date1904: bool) -> Date
|
|
137
138
|
|
|
@@ -140,25 +141,60 @@ module Xlsxrb
|
|
|
140
141
|
# @example
|
|
141
142
|
# Xlsxrb::Utils.datetime_to_serial(Time.utc(2026, 1, 1, 12, 0, 0)) #=> 46023.5
|
|
142
143
|
#
|
|
144
|
+
# @deprecated Use {Xlsxrb.time_to_serial} instead. Will be removed in 0.2.0.
|
|
143
145
|
# @param time [Time, Date] Time or Date instance.
|
|
144
146
|
# @param date1904 [Boolean] Whether to use the 1904 date system.
|
|
145
147
|
# @return [Float] Fractional serial number.
|
|
146
|
-
# @api public
|
|
147
148
|
# : (Time | Date time, ?date1904: bool) -> Float
|
|
148
149
|
def self.datetime_to_serial: (Time | Date time, ?date1904: bool) -> Float
|
|
149
150
|
|
|
151
|
+
# Converts a Time or Date to a fractional Excel serial number.
|
|
152
|
+
#
|
|
153
|
+
# @example
|
|
154
|
+
# Xlsxrb::Utils.time_to_serial(Time.utc(2026, 1, 1, 12, 0, 0)) #=> 46023.5
|
|
155
|
+
#
|
|
156
|
+
# @deprecated Use {Xlsxrb.time_to_serial} instead. Will be removed in 0.2.0.
|
|
157
|
+
# @param time [Time, Date] Time or Date instance.
|
|
158
|
+
# @param date1904 [Boolean] Whether to use the 1904 date system.
|
|
159
|
+
# @return [Float] Fractional serial number.
|
|
160
|
+
# : (Time | Date time, ?date1904: bool) -> Float
|
|
161
|
+
def self.time_to_serial: (Time | Date time, ?date1904: bool) -> Float
|
|
162
|
+
|
|
150
163
|
# Converts an Excel serial number to a Time (UTC).
|
|
151
164
|
#
|
|
152
165
|
# @example
|
|
153
166
|
# Xlsxrb::Utils.serial_to_time(46023.5) #=> 2026-01-01 12:00:00 UTC
|
|
154
167
|
#
|
|
168
|
+
# @deprecated Use {Xlsxrb.serial_to_time} instead. Will be removed in 0.2.0.
|
|
155
169
|
# @param serial [Numeric] Excel serial number.
|
|
156
170
|
# @param date1904 [Boolean] Whether to use the 1904 date system.
|
|
157
171
|
# @return [Time]
|
|
158
|
-
# @api public
|
|
159
172
|
# : (Numeric serial, ?date1904: bool) -> Time
|
|
160
173
|
def self.serial_to_time: (Numeric serial, ?date1904: bool) -> Time
|
|
161
174
|
|
|
162
|
-
|
|
175
|
+
FORMULA_TOKEN_RE: ::Regexp
|
|
176
|
+
|
|
177
|
+
# Expands a formula by shifting relative cell references from a master cell to a target cell.
|
|
178
|
+
#
|
|
179
|
+
# @example Shift formula down one row
|
|
180
|
+
# Xlsxrb::Utils.expand_formula("A2*2", from_ref: "B2", to_ref: "B3") #=> "A3*2"
|
|
181
|
+
#
|
|
182
|
+
# @example Shift formula with absolute references
|
|
183
|
+
# Xlsxrb::Utils.expand_formula("$A$1+A2", from_ref: "B2", to_ref: "B4") #=> "$A$1+A4"
|
|
184
|
+
#
|
|
185
|
+
# @deprecated Use {Xlsxrb.expand_formula} instead. Will be removed in 0.2.0.
|
|
186
|
+
# @param formula [String, nil] Formula expression to expand.
|
|
187
|
+
# @param from_ref [String, nil] Master cell reference (e.g. "B2").
|
|
188
|
+
# @param to_ref [String, nil] Target cell reference (e.g. "B3").
|
|
189
|
+
# @param row_delta [Integer, nil] Row shift amount (positive = down, negative = up).
|
|
190
|
+
# @param column_delta [Integer, nil] Column shift amount (positive = right, negative = left).
|
|
191
|
+
# @param col_delta [Integer, nil] Deprecated alias for column_delta.
|
|
192
|
+
# @return [String, nil] Expanded formula expression.
|
|
193
|
+
# : (String? formula, ?from_ref: String?, ?to_ref: String?, ?row_delta: Integer?, ?col_delta: Integer?, ?column_delta: Integer?) -> String?
|
|
194
|
+
def self.expand_formula: (String? formula, ?from_ref: String?, ?to_ref: String?, ?row_delta: Integer?, ?col_delta: Integer?, ?column_delta: Integer?) -> String?
|
|
195
|
+
|
|
196
|
+
# @deprecated Use {Xlsxrb.serial_to_time} instead. Will be removed in 0.2.0.
|
|
197
|
+
# : (Numeric serial, ?date1904: bool) -> Time
|
|
198
|
+
def self.serial_to_datetime: (Numeric serial, ?date1904: bool) -> Time
|
|
163
199
|
end
|
|
164
200
|
end
|
|
@@ -15,8 +15,190 @@ module Xlsxrb
|
|
|
15
15
|
# @api public
|
|
16
16
|
class WorkbookBuilder
|
|
17
17
|
# @param strict_excel_mode [Boolean] Whether to enforce Microsoft Excel specifications.
|
|
18
|
-
#
|
|
19
|
-
|
|
18
|
+
# @param escape_formulas [Boolean] Whether to treat strings starting with formula prefixes as plain text.
|
|
19
|
+
# @param default_font [Hash, nil] Optional default font options (e.g. `{ name: "Arial", size: 12 }`).
|
|
20
|
+
# : (?strict_excel_mode: bool, ?escape_formulas: bool, ?default_font: untyped?) -> void
|
|
21
|
+
def initialize: (?strict_excel_mode: bool, ?escape_formulas: bool, ?default_font: untyped?) -> void
|
|
22
|
+
|
|
23
|
+
# @return [Boolean] Whether to treat strings starting with formula prefixes as plain text.
|
|
24
|
+
# : bool
|
|
25
|
+
attr_accessor escape_formulas: untyped
|
|
26
|
+
|
|
27
|
+
# Returns whether formula escaping is enabled.
|
|
28
|
+
#
|
|
29
|
+
# @return [Boolean]
|
|
30
|
+
# @api public
|
|
31
|
+
# : () -> bool
|
|
32
|
+
def escape_formulas?: () -> bool
|
|
33
|
+
|
|
34
|
+
# Sets or configures the workbook-wide default font.
|
|
35
|
+
#
|
|
36
|
+
# @param name [String, Hash, nil] Font name or font options Hash.
|
|
37
|
+
# @param size [Float, Integer, nil] Font size in points.
|
|
38
|
+
# @param opts [Hash] Additional font options (e.g. `bold:`, `italic:`, `family:`, `charset:`, `color:`).
|
|
39
|
+
# @return [void]
|
|
40
|
+
# @api public
|
|
41
|
+
# : (?String | Hash[Symbol, untyped]? name, ?Float | Integer | nil size, **untyped opts) -> void
|
|
42
|
+
def default_font: (?String | Hash[Symbol, untyped]? name, ?Float | Integer | nil size, **untyped opts) -> void
|
|
43
|
+
|
|
44
|
+
# @deprecated Use {#default_font} instead. Will be removed in 0.2.0.
|
|
45
|
+
alias set_default_font default_font
|
|
46
|
+
|
|
47
|
+
# @return [Hash{String => StyleBuilder}]
|
|
48
|
+
# : Hash[String, StyleBuilder]
|
|
49
|
+
attr_reader styles: untyped
|
|
50
|
+
|
|
51
|
+
# Defines or configures a named cell style at the workbook level.
|
|
52
|
+
#
|
|
53
|
+
# @example
|
|
54
|
+
# workbook.style(:header, bold: true, fill_color: "4F81BD", font_color: "FFFFFF")
|
|
55
|
+
#
|
|
56
|
+
# @param name [String, Symbol] The name of the style.
|
|
57
|
+
# @param opts [Hash] Style options (e.g. bold: true, fill_color: "FF0000").
|
|
58
|
+
# @yield [style_builder]
|
|
59
|
+
# @yieldparam style_builder [Xlsxrb::StyleBuilder]
|
|
60
|
+
# @return [StyleBuilder]
|
|
61
|
+
# @api public
|
|
62
|
+
# : (String | Symbol name, **untyped opts) ?{ (StyleBuilder) -> void } -> StyleBuilder
|
|
63
|
+
def style: (String | Symbol name, **untyped opts) ?{ (StyleBuilder) -> void } -> StyleBuilder
|
|
64
|
+
|
|
65
|
+
# Creates an {Elements::Formula} object.
|
|
66
|
+
#
|
|
67
|
+
# @param expression [String] The formula expression without leading '='.
|
|
68
|
+
# @param cached_value [Object, nil] Optional precomputed value.
|
|
69
|
+
# @param type [Symbol, String, nil] Formula type (:shared, :array, etc.).
|
|
70
|
+
# @param ref [String, nil] Target cell or range reference.
|
|
71
|
+
# @param shared_index [Integer, nil] Shared formula group index (0-based).
|
|
72
|
+
# @return [Elements::Formula]
|
|
73
|
+
# @api public
|
|
74
|
+
# : (String expression, ?cached_value: (String | Numeric | bool | Elements::CellError | nil), ?type: (Symbol | String)?, ?ref: String?, ?shared_index: Integer?) -> Elements::Formula
|
|
75
|
+
def formula: (String expression, ?cached_value: String | Numeric | bool | Elements::CellError | nil, ?type: (Symbol | String)?, ?ref: String?, ?shared_index: Integer?) -> Elements::Formula
|
|
76
|
+
|
|
77
|
+
# Creates an array or dynamic array {Elements::Formula} object.
|
|
78
|
+
#
|
|
79
|
+
# @param expression [String] The formula expression without leading '='.
|
|
80
|
+
# @param ref [String, nil] Target cell or range reference (keyword).
|
|
81
|
+
# @param cached_value [Object, nil] Optional precomputed value.
|
|
82
|
+
# @return [Elements::Formula]
|
|
83
|
+
# @api public
|
|
84
|
+
# : (String expression, ?ref: String?, ?cached_value: (String | Numeric | bool | Elements::CellError | nil), **untyped attrs) -> Elements::Formula
|
|
85
|
+
def array_formula: (String expression, ?ref: String?, ?cached_value: String | Numeric | bool | Elements::CellError | nil, **untyped attrs) -> Elements::Formula
|
|
86
|
+
|
|
87
|
+
# Creates a shared formula {Elements::Formula} object.
|
|
88
|
+
#
|
|
89
|
+
# @param expression [String, nil] The formula expression.
|
|
90
|
+
# @param shared_index [Integer, nil] Shared formula group index (0-based).
|
|
91
|
+
# @param ref [String, nil] Target range for master cell.
|
|
92
|
+
# @param cached_value [Object, nil] Optional precomputed value.
|
|
93
|
+
# @return [Elements::Formula]
|
|
94
|
+
# @api public
|
|
95
|
+
# : (?String? expression, ?shared_index: Integer?, ?ref: String?, ?cached_value: (String | Numeric | bool | Elements::CellError | nil)) -> Elements::Formula
|
|
96
|
+
def shared_formula: (?String? expression, ?shared_index: Integer?, ?ref: String?, ?cached_value: String | Numeric | bool | Elements::CellError | nil) -> Elements::Formula
|
|
97
|
+
|
|
98
|
+
# Creates an {Elements::RichText} object.
|
|
99
|
+
#
|
|
100
|
+
# @param runs [Array] Text runs or styling options.
|
|
101
|
+
# @return [Elements::RichText]
|
|
102
|
+
# @api public
|
|
103
|
+
# : (*(Hash[Symbol, untyped] | Elements::RichTextRun | String | Array[untyped] | untyped) runs, ?text: String?, ?base_font: untyped, **untyped font_props) -> Elements::RichText
|
|
104
|
+
def rich_text: (*Hash[Symbol, untyped] | Elements::RichTextRun | String | Array[untyped] | untyped runs, ?text: String?, ?base_font: untyped, **untyped font_props) -> Elements::RichText
|
|
105
|
+
|
|
106
|
+
# Creates or returns an {Elements::CellError} object.
|
|
107
|
+
#
|
|
108
|
+
# @param code [String, Symbol, Elements::CellError] Error code or symbol.
|
|
109
|
+
# @return [Elements::CellError]
|
|
110
|
+
# @api public
|
|
111
|
+
# : (String | Symbol | Elements::CellError code) -> Elements::CellError
|
|
112
|
+
def cell_error: (String | Symbol | Elements::CellError code) -> Elements::CellError
|
|
113
|
+
|
|
114
|
+
OMITTED: untyped
|
|
115
|
+
|
|
116
|
+
# Gets or sets the active worksheet tab in the workbook window.
|
|
117
|
+
#
|
|
118
|
+
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#active_sheet=} instead.
|
|
119
|
+
# @param name_or_index [String, Symbol, Integer, nil] Sheet name or 0-based sheet index.
|
|
120
|
+
# @return [String, Symbol, Integer, nil]
|
|
121
|
+
# @api public
|
|
122
|
+
# : (?String | Symbol | Integer | nil name_or_index) -> (String | Symbol | Integer | nil)
|
|
123
|
+
def active_sheet: (?String | Symbol | Integer | nil name_or_index) -> (String | Symbol | Integer | nil)
|
|
124
|
+
|
|
125
|
+
# @deprecated Use {#active_sheet} instead. Will be removed in 0.2.0.
|
|
126
|
+
alias active_tab active_sheet
|
|
127
|
+
|
|
128
|
+
# Sets the active worksheet tab in the workbook window.
|
|
129
|
+
#
|
|
130
|
+
# @param name_or_index [String, Symbol, Integer, nil] Sheet name or 0-based sheet index.
|
|
131
|
+
# @return [String, Symbol, Integer, nil]
|
|
132
|
+
# @api public
|
|
133
|
+
attr_writer active_sheet: String | Symbol | Integer | nil
|
|
134
|
+
|
|
135
|
+
# @deprecated Use {#active_sheet=} instead. Will be removed in 0.2.0.
|
|
136
|
+
alias active_tab= active_sheet=
|
|
137
|
+
|
|
138
|
+
# Gets or sets the first sheet tab visible in the sheet tab scroll area.
|
|
139
|
+
#
|
|
140
|
+
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#first_sheet=} instead.
|
|
141
|
+
# @param name_or_index [String, Symbol, Integer, nil] Sheet name or 0-based sheet index.
|
|
142
|
+
# @return [String, Symbol, Integer, nil]
|
|
143
|
+
# @api public
|
|
144
|
+
# : (?String | Symbol | Integer | nil name_or_index) -> (String | Symbol | Integer | nil)
|
|
145
|
+
def first_sheet: (?String | Symbol | Integer | nil name_or_index) -> (String | Symbol | Integer | nil)
|
|
146
|
+
|
|
147
|
+
# Sets the first sheet tab visible in the sheet tab scroll area.
|
|
148
|
+
#
|
|
149
|
+
# @param name_or_index [String, Symbol, Integer, nil] Sheet name or 0-based sheet index.
|
|
150
|
+
# @return [String, Symbol, Integer, nil]
|
|
151
|
+
# @api public
|
|
152
|
+
attr_writer first_sheet: String | Symbol | Integer | nil
|
|
153
|
+
|
|
154
|
+
# Gets or sets whether sheet tabs are visible in the workbook window.
|
|
155
|
+
#
|
|
156
|
+
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#show_sheet_tabs=} instead.
|
|
157
|
+
# @param visible [Boolean, nil]
|
|
158
|
+
# @return [Boolean, nil]
|
|
159
|
+
# @api public
|
|
160
|
+
# : (?bool? visible) -> bool?
|
|
161
|
+
def show_sheet_tabs: (?bool? visible) -> bool?
|
|
162
|
+
|
|
163
|
+
# Sets whether sheet tabs are visible in the workbook window.
|
|
164
|
+
#
|
|
165
|
+
# @param visible [Boolean, nil]
|
|
166
|
+
# @return [Boolean, nil]
|
|
167
|
+
# @api public
|
|
168
|
+
attr_writer show_sheet_tabs: bool?
|
|
169
|
+
|
|
170
|
+
# Gets or sets the ratio between the sheet tabs bar and the horizontal scroll bar (0-1000).
|
|
171
|
+
#
|
|
172
|
+
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#tab_ratio=} instead.
|
|
173
|
+
# @param ratio [Integer, nil]
|
|
174
|
+
# @return [Integer, nil]
|
|
175
|
+
# @api public
|
|
176
|
+
# : (?Integer? ratio) -> Integer?
|
|
177
|
+
def tab_ratio: (?Integer? ratio) -> Integer?
|
|
178
|
+
|
|
179
|
+
# Sets the ratio between the sheet tabs bar and the horizontal scroll bar (0-1000).
|
|
180
|
+
#
|
|
181
|
+
# @param ratio [Integer, nil]
|
|
182
|
+
# @return [Integer, nil]
|
|
183
|
+
# @api public
|
|
184
|
+
attr_writer tab_ratio: Integer?
|
|
185
|
+
|
|
186
|
+
# Gets or sets the internal code name of the workbook.
|
|
187
|
+
#
|
|
188
|
+
# @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#code_name=} instead.
|
|
189
|
+
# @param name [String, Symbol, nil] The code name.
|
|
190
|
+
# @return [String, nil]
|
|
191
|
+
# @api public
|
|
192
|
+
# : (?String | Symbol | nil name) -> String?
|
|
193
|
+
def code_name: (?String | Symbol | nil name) -> String?
|
|
194
|
+
|
|
195
|
+
# Sets the internal code name of the workbook.
|
|
196
|
+
#
|
|
197
|
+
# @param name [String, Symbol, nil] The code name.
|
|
198
|
+
# @return [String, nil]
|
|
199
|
+
# @api public
|
|
200
|
+
# : (String | Symbol | nil name) -> String?
|
|
201
|
+
def code_name=: (String | Symbol | nil name) -> String?
|
|
20
202
|
|
|
21
203
|
# Sets a workbook-level property.
|
|
22
204
|
#
|
|
@@ -28,52 +210,119 @@ module Xlsxrb
|
|
|
28
210
|
# @param value [String, Integer, Boolean] Property value.
|
|
29
211
|
# @return [void]
|
|
30
212
|
# @api public
|
|
31
|
-
# : (Symbol name, String | Integer | bool value) ->
|
|
32
|
-
def workbook_property: (Symbol name, String | Integer | bool value) ->
|
|
213
|
+
# : (Symbol name, String | Integer | bool value) -> void
|
|
214
|
+
def workbook_property: (Symbol name, String | Integer | bool value) -> void
|
|
215
|
+
|
|
216
|
+
# Returns workbook-level properties.
|
|
217
|
+
#
|
|
218
|
+
# @return [Elements::WorkbookProperties]
|
|
219
|
+
# @api public
|
|
220
|
+
# : () -> Elements::WorkbookProperties
|
|
221
|
+
def workbook_properties: () -> Elements::WorkbookProperties
|
|
222
|
+
|
|
223
|
+
# Sets workbook-level properties.
|
|
224
|
+
#
|
|
225
|
+
# @param props [Hash, Elements::MetadataRecord]
|
|
226
|
+
# @return [void]
|
|
227
|
+
# @api public
|
|
228
|
+
# : (untyped props) -> void
|
|
229
|
+
def workbook_properties=: (untyped props) -> void
|
|
230
|
+
|
|
231
|
+
# Returns the list of worksheet names added to this workbook so far.
|
|
232
|
+
#
|
|
233
|
+
# @return [Array<String>] Worksheet names.
|
|
234
|
+
# @api public
|
|
235
|
+
# : () -> Array[String]
|
|
236
|
+
def sheet_names: () -> Array[String]
|
|
33
237
|
|
|
34
238
|
# Adds a new worksheet to the workbook.
|
|
35
239
|
#
|
|
36
|
-
# @param name [String, nil] Sheet name (max 31 chars, no forbidden chars `[ ] * ? /
|
|
37
|
-
# @param
|
|
240
|
+
# @param name [String, nil] Sheet name (max 31 chars, no forbidden chars `[ ] * ? / \ :`).
|
|
241
|
+
# @param state [Symbol, String, nil] Sheet visibility state (:visible, :hidden, :very_hidden).
|
|
242
|
+
# @param tab_color [String, Hash, nil] Tab color hex string or color hash.
|
|
243
|
+
# @param code_name [String, nil] VBA code name.
|
|
244
|
+
# @param hidden [Boolean, nil] Deprecated alias for state: :hidden.
|
|
245
|
+
# @param opts [Hash] Additional sheet properties.
|
|
38
246
|
# @yield [sheet_builder]
|
|
39
247
|
# @yieldparam sheet_builder [Xlsxrb::WorksheetBuilder]
|
|
40
248
|
# @return [Elements::Worksheet]
|
|
41
249
|
# @raise [ArgumentError] If sheet name violates Excel limits in strict mode.
|
|
42
250
|
# @api public
|
|
43
|
-
# : (?String? name, **untyped opts) ?{ (WorksheetBuilder) -> void } ->
|
|
44
|
-
def sheet: (?String? name, **untyped opts) ?{ (WorksheetBuilder) -> void } ->
|
|
251
|
+
# : (?String? name, ?state: (Symbol | String)?, ?tab_color: untyped, ?code_name: String?, ?hidden: bool?, **untyped opts) ?{ (WorksheetBuilder) -> void } -> Elements::Worksheet
|
|
252
|
+
def sheet: (?String? name, ?state: (Symbol | String)?, ?tab_color: untyped, ?code_name: String?, ?hidden: bool?, **untyped opts) ?{ (WorksheetBuilder) -> void } -> Elements::Worksheet
|
|
45
253
|
|
|
46
|
-
|
|
254
|
+
# Accesses or defines a worksheet by name.
|
|
255
|
+
#
|
|
256
|
+
# @param name_or_index [String, Symbol, Integer, nil]
|
|
257
|
+
# @yield [sheet_builder]
|
|
258
|
+
# @return [Elements::Worksheet]
|
|
259
|
+
# @api public
|
|
260
|
+
# : (?String | Symbol | Integer | nil name_or_index) ?{ (WorksheetBuilder) -> void } -> Elements::Worksheet
|
|
261
|
+
def []: (?String | Symbol | Integer | nil name_or_index) ?{ (WorksheetBuilder) -> void } -> Elements::Worksheet
|
|
47
262
|
|
|
48
|
-
# Adds a defined name (named range or formula
|
|
263
|
+
# Adds a defined name (named range or formula) to the workbook.
|
|
264
|
+
# Bare cell references and coordinate keywords are automatically formatted with sheet quotes and absolute $ references.
|
|
49
265
|
#
|
|
50
|
-
# @param name [String] Defined name
|
|
51
|
-
# @param value [
|
|
52
|
-
# @param sheet [String, nil]
|
|
266
|
+
# @param name [String] Defined name identifier.
|
|
267
|
+
# @param value [Object, nil] Value or formula expression.
|
|
268
|
+
# @param sheet [String, nil] Reference sheet name for coordinates/formula.
|
|
269
|
+
# @param scope [String, Symbol, nil] Optional sheet name or :workbook for scope (defaults to workbook).
|
|
53
270
|
# @param hidden [Boolean] Whether the defined name is hidden from Excel's UI.
|
|
271
|
+
# @param column [Integer, String, nil] Deprecated alias for columns.
|
|
272
|
+
# @param columns [Integer, String, nil] Column index or letter for coordinate-based reference.
|
|
273
|
+
# @param col [Integer, String, nil] Deprecated alias for column.
|
|
274
|
+
# @param row [Integer, Range, nil] Deprecated alias for rows.
|
|
275
|
+
# @param rows [Integer, Range, nil] Row or row range (1-based) for coordinate-based reference.
|
|
276
|
+
# @param range [String, nil] Cell range reference.
|
|
277
|
+
# @param ref_sheet [String, nil] Deprecated alias for sheet.
|
|
278
|
+
# @param local [Boolean] Deprecated alias for scope.
|
|
54
279
|
# @return [void]
|
|
55
280
|
# @api public
|
|
56
|
-
# : (String name,
|
|
57
|
-
def defined_name: (String name,
|
|
281
|
+
# : (String name, ?untyped value, ?sheet: String?, ?scope: (String | Symbol)?, ?hidden: bool, ?column: untyped, ?columns: untyped, ?col: untyped, ?row: untyped, ?rows: untyped, ?range: untyped, ?ref_sheet: String?, ?local: bool) -> void
|
|
282
|
+
def defined_name: (String name, ?untyped value, ?sheet: String?, ?scope: (String | Symbol)?, ?hidden: bool, ?column: untyped, ?columns: untyped, ?col: untyped, ?row: untyped, ?rows: untyped, ?range: untyped, ?ref_sheet: String?, ?local: bool) -> void
|
|
283
|
+
|
|
284
|
+
# Returns workbook-level defined names.
|
|
285
|
+
#
|
|
286
|
+
# @return [Array<Elements::DefinedName>]
|
|
287
|
+
# @api public
|
|
288
|
+
# : () -> Array[Elements::DefinedName]
|
|
289
|
+
def defined_names: () -> Array[Elements::DefinedName]
|
|
58
290
|
|
|
59
|
-
# Sets the print area for a sheet.
|
|
291
|
+
# Sets or gets the print area for a sheet.
|
|
60
292
|
#
|
|
61
|
-
# @param range [String] Cell range (e.g. "A1:G50").
|
|
293
|
+
# @param range [String, Object, nil] Cell range (e.g. "A1:G50").
|
|
62
294
|
# @param sheet [String, nil] Target sheet name (defaults to latest or "Sheet1").
|
|
63
|
-
# @return [void]
|
|
295
|
+
# @return [String, nil, void]
|
|
296
|
+
# @api public
|
|
297
|
+
# : (?untyped range, ?sheet: String?) -> (String | nil | void)
|
|
298
|
+
def print_area: (?untyped range, ?sheet: untyped) -> untyped
|
|
299
|
+
|
|
300
|
+
# Sets the print area for the worksheet.
|
|
301
|
+
#
|
|
302
|
+
# @param range [String, nil] Cell range (e.g. "A1:G50").
|
|
303
|
+
# @return [String, nil]
|
|
64
304
|
# @api public
|
|
65
|
-
# : (String range
|
|
66
|
-
def print_area
|
|
305
|
+
# : (String? range) -> String?
|
|
306
|
+
def print_area=: (String? range) -> String?
|
|
67
307
|
|
|
68
308
|
# Sets repeating print titles (rows and/or columns) for pagination.
|
|
69
309
|
#
|
|
70
310
|
# @param rows [String, nil] Repeating row range (e.g. "1:2").
|
|
71
|
-
# @param
|
|
311
|
+
# @param columns [String, nil] Repeating column range (e.g. "A:B").
|
|
312
|
+
# @param cols [String, nil] Deprecated alias for columns.
|
|
72
313
|
# @param sheet [String, nil] Target sheet name.
|
|
73
314
|
# @return [void]
|
|
74
315
|
# @api public
|
|
75
|
-
# : (?rows: String?, ?cols: String?, ?sheet: String?) -> void
|
|
76
|
-
def print_titles: (?rows: String?, ?cols: String?, ?sheet: String?) -> void
|
|
316
|
+
# : (?rows: (String | Integer | Range[Integer])?, ?columns: (String | Integer | Symbol | Range[untyped])?, ?cols: (String | Integer | Symbol | Range[untyped])?, ?sheet: String?) -> void
|
|
317
|
+
def print_titles: (?rows: (String | Integer | Range[Integer])?, ?columns: (String | Integer | Symbol | Range[untyped])?, ?cols: (String | Integer | Symbol | Range[untyped])?, ?sheet: String?) -> void
|
|
318
|
+
|
|
319
|
+
# Sets repeating print titles.
|
|
320
|
+
#
|
|
321
|
+
# @param opts [Elements::PrintTitles, Hash] Options with :rows and/or :columns.
|
|
322
|
+
# @return [Elements::PrintTitles, Hash]
|
|
323
|
+
# @api public
|
|
324
|
+
# : (Elements::PrintTitles | Hash[Symbol, untyped] opts) -> (Elements::PrintTitles | Hash[Symbol, untyped])
|
|
325
|
+
def print_titles=: (Elements::PrintTitles | Hash[Symbol, untyped] opts) -> (Elements::PrintTitles | Hash[Symbol, untyped])
|
|
77
326
|
|
|
78
327
|
# Sets repeating title rows for pagination on the target or active sheet.
|
|
79
328
|
#
|
|
@@ -101,11 +350,23 @@ module Xlsxrb
|
|
|
101
350
|
# : (Integer | String first, ?(Integer | String)? last, ?sheet: String?) -> void
|
|
102
351
|
def repeat_columns: (Integer | String first, ?(Integer | String)? last, ?sheet: String?) -> void
|
|
103
352
|
|
|
104
|
-
# Sets workbook structure and window protection.
|
|
353
|
+
# Sets or returns workbook structure and window protection.
|
|
105
354
|
#
|
|
106
355
|
# @param opts [Hash] Protection options (e.g. lock_structure: true, password: "secret").
|
|
356
|
+
# @return [Elements::WorkbookProtection, nil, void]
|
|
357
|
+
# @api public
|
|
358
|
+
# : (**String | Integer | bool | nil opts) -> (Elements::WorkbookProtection | nil)
|
|
359
|
+
def workbook_protection: (**String | Integer | bool | nil opts) -> (Elements::WorkbookProtection | nil)
|
|
360
|
+
|
|
361
|
+
# Sets workbook protection settings.
|
|
362
|
+
#
|
|
363
|
+
# @param opts [Hash, Elements::MetadataRecord, nil]
|
|
107
364
|
# @return [void]
|
|
108
365
|
# @api public
|
|
366
|
+
# : (untyped opts) -> void
|
|
367
|
+
def workbook_protection=: (untyped opts) -> void
|
|
368
|
+
|
|
369
|
+
# @deprecated Use {#workbook_protection} instead.
|
|
109
370
|
# : (**String | Integer | bool | nil opts) -> void
|
|
110
371
|
def protect_workbook: (**String | Integer | bool | nil opts) -> void
|
|
111
372
|
|
|
@@ -118,6 +379,13 @@ module Xlsxrb
|
|
|
118
379
|
# : (Symbol name, String | Integer | Time value) -> void
|
|
119
380
|
def core_property: (Symbol name, String | Integer | Time value) -> void
|
|
120
381
|
|
|
382
|
+
# Returns core document properties.
|
|
383
|
+
#
|
|
384
|
+
# @return [Elements::CoreProperties]
|
|
385
|
+
# @api public
|
|
386
|
+
# : () -> Elements::CoreProperties
|
|
387
|
+
def core_properties: () -> Elements::CoreProperties
|
|
388
|
+
|
|
121
389
|
# Sets an extended application metadata property.
|
|
122
390
|
#
|
|
123
391
|
# @param name [Symbol] Application property name (:company, :manager, :app_version, etc.).
|
|
@@ -127,6 +395,13 @@ module Xlsxrb
|
|
|
127
395
|
# : (Symbol name, String | Integer | Time value) -> void
|
|
128
396
|
def app_property: (Symbol name, String | Integer | Time value) -> void
|
|
129
397
|
|
|
398
|
+
# Returns application document properties.
|
|
399
|
+
#
|
|
400
|
+
# @return [Elements::AppProperties]
|
|
401
|
+
# @api public
|
|
402
|
+
# : () -> Elements::AppProperties
|
|
403
|
+
def app_properties: () -> Elements::AppProperties
|
|
404
|
+
|
|
130
405
|
# Sets multiple core, app, and/or custom properties simultaneously.
|
|
131
406
|
#
|
|
132
407
|
# @param core [Hash{Symbol => Object}, nil] Core properties map.
|
|
@@ -147,6 +422,13 @@ module Xlsxrb
|
|
|
147
422
|
# : (String name, String | Integer | Float | bool | Time value, ?type: ::Symbol) -> void
|
|
148
423
|
def custom_property: (String name, String | Integer | Float | bool | Time value, ?type: ::Symbol) -> void
|
|
149
424
|
|
|
425
|
+
# Returns custom document properties.
|
|
426
|
+
#
|
|
427
|
+
# @return [Hash<String, Elements::CustomProperty>]
|
|
428
|
+
# @api public
|
|
429
|
+
# : () -> Hash[String, Elements::CustomProperty]
|
|
430
|
+
def custom_properties: () -> Hash[String, Elements::CustomProperty]
|
|
431
|
+
|
|
150
432
|
# Builds and returns the compiled {Elements::Workbook}.
|
|
151
433
|
#
|
|
152
434
|
# @return [Elements::Workbook]
|
|
@@ -166,7 +448,7 @@ module Xlsxrb
|
|
|
166
448
|
# : (untyped sheets) -> (::Array[untyped | ::Hash[untyped, untyped]] | ::Array[untyped])
|
|
167
449
|
def process_styles: (untyped sheets) -> (::Array[untyped | ::Hash[untyped, untyped]] | ::Array[untyped])
|
|
168
450
|
|
|
169
|
-
# : (untyped writer) ->
|
|
170
|
-
def extract_styles_from_writer: (untyped writer) ->
|
|
451
|
+
# : (untyped writer) -> Hash[Symbol, untyped]
|
|
452
|
+
def extract_styles_from_writer: (untyped writer) -> Hash[Symbol, untyped]
|
|
171
453
|
end
|
|
172
454
|
end
|