xlsxrb 0.1.13 → 0.1.14
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 +57 -0
- data/README.md +2 -0
- data/lib/xlsxrb/colors.rb +118 -0
- data/lib/xlsxrb/elements/cell.rb +205 -16
- data/lib/xlsxrb/elements/column.rb +6 -4
- data/lib/xlsxrb/elements/coordinate_access.rb +32 -0
- data/lib/xlsxrb/elements/image.rb +128 -0
- data/lib/xlsxrb/elements/row.rb +206 -9
- data/lib/xlsxrb/elements/styles.rb +157 -0
- data/lib/xlsxrb/elements/types.rb +95 -1
- data/lib/xlsxrb/elements/workbook.rb +85 -4
- data/lib/xlsxrb/elements/worksheet.rb +424 -29
- data/lib/xlsxrb/elements.rb +2 -0
- data/lib/xlsxrb/number_formatter.rb +429 -0
- data/lib/xlsxrb/ooxml/cfb.rb +1 -1
- data/lib/xlsxrb/ooxml/reader/listeners/core_listeners.rb +7 -5
- data/lib/xlsxrb/ooxml/reader/listeners/drawing_listeners.rb +11 -4
- data/lib/xlsxrb/ooxml/reader.rb +12 -14
- data/lib/xlsxrb/ooxml/shared_strings_parser.rb +7 -1
- data/lib/xlsxrb/ooxml/styles_parser.rb +39 -9
- data/lib/xlsxrb/ooxml/utils.rb +34 -18
- data/lib/xlsxrb/ooxml/workbook_parser.rb +53 -15
- data/lib/xlsxrb/ooxml/workbook_writer.rb +65 -14
- data/lib/xlsxrb/ooxml/worksheet_parser.rb +319 -79
- data/lib/xlsxrb/ooxml/worksheet_writer.rb +206 -61
- data/lib/xlsxrb/ooxml/writer/features_xml.rb +4 -2
- data/lib/xlsxrb/ooxml/writer.rb +14 -0
- data/lib/xlsxrb/ooxml/zip_reader.rb +109 -25
- data/lib/xlsxrb/stream_row.rb +243 -16
- data/lib/xlsxrb/stream_sheet.rb +414 -15
- data/lib/xlsxrb/stream_writer.rb +213 -17
- data/lib/xlsxrb/style_builder.rb +308 -22
- data/lib/xlsxrb/utils.rb +158 -0
- data/lib/xlsxrb/version.rb +1 -1
- data/lib/xlsxrb/workbook_builder.rb +73 -3
- data/lib/xlsxrb/worksheet_builder.rb +227 -16
- data/lib/xlsxrb.rb +578 -79
- data/sig/generated/xlsxrb/colors.rbs +40 -0
- data/sig/generated/xlsxrb/elements/cell.rbs +113 -8
- data/sig/generated/xlsxrb/elements/column.rbs +3 -2
- data/sig/generated/xlsxrb/elements/coordinate_access.rbs +18 -0
- data/sig/generated/xlsxrb/elements/image.rbs +82 -0
- data/sig/generated/xlsxrb/elements/row.rbs +83 -4
- data/sig/generated/xlsxrb/elements/styles.rbs +79 -0
- data/sig/generated/xlsxrb/elements/types.rbs +43 -0
- data/sig/generated/xlsxrb/elements/workbook.rbs +51 -2
- data/sig/generated/xlsxrb/elements/worksheet.rbs +231 -18
- data/sig/generated/xlsxrb/number_formatter.rbs +132 -0
- data/sig/generated/xlsxrb/ooxml/reader.rbs +6 -0
- data/sig/generated/xlsxrb/ooxml/shared_strings_parser.rbs +2 -0
- data/sig/generated/xlsxrb/ooxml/styles_parser.rbs +5 -2
- data/sig/generated/xlsxrb/ooxml/utils.rbs +17 -8
- data/sig/generated/xlsxrb/ooxml/workbook_parser.rbs +9 -3
- data/sig/generated/xlsxrb/ooxml/worksheet_parser.rbs +28 -6
- data/sig/generated/xlsxrb/ooxml/worksheet_writer.rbs +3 -1
- data/sig/generated/xlsxrb/ooxml/writer.rbs +2 -0
- data/sig/generated/xlsxrb/ooxml/zip_reader.rbs +10 -0
- data/sig/generated/xlsxrb/stream_row.rbs +100 -6
- data/sig/generated/xlsxrb/stream_sheet.rbs +247 -13
- data/sig/generated/xlsxrb/stream_writer.rbs +120 -14
- data/sig/generated/xlsxrb/style_builder.rbs +55 -18
- data/sig/generated/xlsxrb/utils.rbs +119 -0
- data/sig/generated/xlsxrb/workbook_builder.rbs +26 -0
- data/sig/generated/xlsxrb/worksheet_builder.rbs +107 -11
- data/sig/generated/xlsxrb.rbs +186 -27
- metadata +11 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Generated from lib/xlsxrb/colors.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Xlsxrb
|
|
4
|
+
# ECMA-376 Part 4 §18.8.27 Standard Indexed Color Palette and utilities.
|
|
5
|
+
module Colors
|
|
6
|
+
# Standard ECMA-376 indexed colors (indices 0 through 63 as 6-character RRGGBB hex strings).
|
|
7
|
+
# Indices 8 through 63 represent the classic 56-color palette.
|
|
8
|
+
INDEXED_COLORS: untyped
|
|
9
|
+
|
|
10
|
+
# Resolves a palette index (0..63) to an RRGGBB hex string (or AARRGGBB if alpha: true).
|
|
11
|
+
#
|
|
12
|
+
# @example
|
|
13
|
+
# Xlsxrb::Colors.palette_color(12) #=> "0000FF"
|
|
14
|
+
# Xlsxrb::Colors.palette_color(12, alpha: true) #=> "FF0000FF"
|
|
15
|
+
#
|
|
16
|
+
# @param index [Object, nil] Palette index (0..63).
|
|
17
|
+
# @param alpha [Boolean] Whether to prefix "FF" alpha channel.
|
|
18
|
+
# @return [String, nil]
|
|
19
|
+
# @api public
|
|
20
|
+
# : (untyped index, ?alpha: bool) -> String?
|
|
21
|
+
def self.palette_color: (untyped index, ?alpha: bool) -> String?
|
|
22
|
+
|
|
23
|
+
# Converts any supported color representation (palette index 0..63, CSS name, #RGB, #RRGGBB, #AARRGGBB, integer RGB)
|
|
24
|
+
# to a normalized hex string.
|
|
25
|
+
#
|
|
26
|
+
# @example
|
|
27
|
+
# Xlsxrb::Colors.to_hex(12) #=> "0000FF"
|
|
28
|
+
# Xlsxrb::Colors.to_hex(12, alpha: true) #=> "FF0000FF"
|
|
29
|
+
# Xlsxrb::Colors.to_hex(:navy) #=> "000080"
|
|
30
|
+
# Xlsxrb::Colors.to_hex("#FF0000") #=> "FF0000"
|
|
31
|
+
# Xlsxrb::Colors.to_hex(0xFF0000) #=> "FF0000"
|
|
32
|
+
#
|
|
33
|
+
# @param color [Integer, String, Symbol, nil]
|
|
34
|
+
# @param alpha [Boolean] Whether to include the alpha channel (default false -> "RRGGBB").
|
|
35
|
+
# @return [String, nil]
|
|
36
|
+
# @api public
|
|
37
|
+
# : (Integer | String | Symbol | nil color, ?alpha: bool) -> String?
|
|
38
|
+
def self.to_hex: (Integer | String | Symbol | nil color, ?alpha: bool) -> String?
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -28,6 +28,16 @@ module Xlsxrb
|
|
|
28
28
|
|
|
29
29
|
attr_reader errors: untyped
|
|
30
30
|
|
|
31
|
+
attr_reader hyperlink: untyped
|
|
32
|
+
|
|
33
|
+
attr_reader comment: untyped
|
|
34
|
+
|
|
35
|
+
attr_reader raw_value: untyped
|
|
36
|
+
|
|
37
|
+
attr_reader format_code: untyped
|
|
38
|
+
|
|
39
|
+
attr_reader date1904: untyped
|
|
40
|
+
|
|
31
41
|
# @param row_index [Integer] 0-based row index.
|
|
32
42
|
# @param column_index [Integer] 0-based column index.
|
|
33
43
|
# @param value [Object, nil] The cell's value.
|
|
@@ -35,10 +45,16 @@ module Xlsxrb
|
|
|
35
45
|
# @param style_index [Integer, String, nil] Style identifier.
|
|
36
46
|
# @param unmapped_data [Hash] Additional metadata.
|
|
37
47
|
# @param errors [Array<String>, nil] Validation errors.
|
|
38
|
-
#
|
|
39
|
-
|
|
48
|
+
# @param hyperlink [Hash, String, Elements::Hyperlink, nil] Optional hyperlink metadata or URL.
|
|
49
|
+
# @param comment [Hash, String, nil] Optional cell comment or note.
|
|
50
|
+
# @param raw_value [String, nil] Optional unparsed raw string value.
|
|
51
|
+
# @param format_code [String, nil] Optional OpenXML number/date format code.
|
|
52
|
+
# @param date1904 [Boolean] Whether the cell belongs to a 1904 date system workbook.
|
|
53
|
+
# : (row_index: untyped, column_index: untyped, ?value: untyped, ?formula: (Elements::Formula | String)?, ?style_index: (Integer | String)?, ?unmapped_data: Hash[untyped, untyped], ?errors: Array[String]?, ?hyperlink: (Hash[Symbol, untyped] | String | Elements::Hyperlink)?, ?comment: (Hash[Symbol, untyped] | String)?, ?raw_value: String?, ?format_code: String?, ?date1904: bool) -> void
|
|
54
|
+
def initialize: (row_index: untyped, column_index: untyped, ?value: untyped, ?formula: (Elements::Formula | String)?, ?style_index: (Integer | String)?, ?unmapped_data: Hash[untyped, untyped], ?errors: Array[String]?, ?hyperlink: (Hash[Symbol, untyped] | String | Elements::Hyperlink)?, ?comment: (Hash[Symbol, untyped] | String)?, ?raw_value: String?, ?format_code: String?, ?date1904: bool) -> void
|
|
40
55
|
|
|
41
|
-
|
|
56
|
+
# rubocop:disable Style/OptionalBooleanParameter
|
|
57
|
+
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
|
|
42
58
|
|
|
43
59
|
def ==: (untyped other) -> untyped
|
|
44
60
|
|
|
@@ -65,14 +81,101 @@ module Xlsxrb
|
|
|
65
81
|
# : () -> String
|
|
66
82
|
def ref: () -> String
|
|
67
83
|
|
|
84
|
+
# Returns whether the cell contains a formula.
|
|
85
|
+
#
|
|
86
|
+
# @return [Boolean]
|
|
87
|
+
# @api public
|
|
88
|
+
# : () -> bool
|
|
89
|
+
def formula?: () -> bool
|
|
90
|
+
|
|
91
|
+
# Returns the formula expression string without leading '=', or nil.
|
|
92
|
+
#
|
|
93
|
+
# @return [String, nil]
|
|
94
|
+
# @api public
|
|
95
|
+
# : () -> String?
|
|
96
|
+
def formula_expression: () -> String?
|
|
97
|
+
|
|
98
|
+
# Returns whether the cell contains a hyperlink.
|
|
99
|
+
#
|
|
100
|
+
# @return [Boolean]
|
|
101
|
+
# @api public
|
|
102
|
+
# : () -> bool
|
|
103
|
+
def link?: () -> bool
|
|
104
|
+
|
|
105
|
+
alias hyperlink? link?
|
|
106
|
+
|
|
107
|
+
# Returns the hyperlink target URL or location string, or nil.
|
|
108
|
+
#
|
|
109
|
+
# @return [String, nil]
|
|
110
|
+
# @api public
|
|
111
|
+
# : () -> String?
|
|
112
|
+
def url: () -> String?
|
|
113
|
+
|
|
114
|
+
# Returns the hyperlink tooltip (ScreenTip) text, or nil.
|
|
115
|
+
#
|
|
116
|
+
# @return [String, nil]
|
|
117
|
+
# @api public
|
|
118
|
+
# : () -> String?
|
|
119
|
+
def tooltip: () -> String?
|
|
120
|
+
|
|
121
|
+
# Returns whether the cell contains a comment or note.
|
|
122
|
+
#
|
|
123
|
+
# @return [Boolean]
|
|
124
|
+
# @api public
|
|
125
|
+
# : () -> bool
|
|
126
|
+
def comment?: () -> bool
|
|
127
|
+
|
|
128
|
+
# Returns the plain text of the cell comment or note, or nil.
|
|
129
|
+
#
|
|
130
|
+
# @return [String, nil]
|
|
131
|
+
# @api public
|
|
132
|
+
# : () -> String?
|
|
133
|
+
def comment_text: () -> String?
|
|
134
|
+
|
|
135
|
+
# Returns the formatted string representation of the cell value according to its format code.
|
|
136
|
+
#
|
|
137
|
+
# @param custom_format_code [String, nil] Optional format code override.
|
|
138
|
+
# @return [String, nil]
|
|
139
|
+
# @api public
|
|
140
|
+
# : (?String? custom_format_code) -> String?
|
|
141
|
+
def formatted_value: (?String? custom_format_code) -> String?
|
|
142
|
+
|
|
68
143
|
# Access cell attributes by Symbol key.
|
|
69
144
|
#
|
|
70
|
-
# @param key [Symbol] Attribute key (:value, :formula, :style_index, :ref, :column_index, :row_index, :type).
|
|
145
|
+
# @param key [Symbol] Attribute key (:value, :formula, :style_index, :ref, :column_index, :row_index, :type, :raw_value, :format_code, :formatted_value).
|
|
71
146
|
# @return [Object, nil]
|
|
72
147
|
# @api public
|
|
73
148
|
# : (Symbol key) -> untyped
|
|
74
149
|
def []: (Symbol key) -> untyped
|
|
75
150
|
|
|
151
|
+
# Returns the classified format category for this cell (:date, :datetime, :time, :number, :text, :general, or nil).
|
|
152
|
+
#
|
|
153
|
+
# @return [Symbol, nil]
|
|
154
|
+
# @api public
|
|
155
|
+
# : () -> Symbol?
|
|
156
|
+
def format_type: () -> Symbol?
|
|
157
|
+
|
|
158
|
+
# Returns whether the cell has a date, datetime, or time format.
|
|
159
|
+
#
|
|
160
|
+
# @return [Boolean]
|
|
161
|
+
# @api public
|
|
162
|
+
# : () -> bool
|
|
163
|
+
def date_format?: () -> bool
|
|
164
|
+
|
|
165
|
+
# Returns whether the cell has a time-only format.
|
|
166
|
+
#
|
|
167
|
+
# @return [Boolean]
|
|
168
|
+
# @api public
|
|
169
|
+
# : () -> bool
|
|
170
|
+
def time_format?: () -> bool
|
|
171
|
+
|
|
172
|
+
# Returns whether the cell's workbook uses the 1904 date system.
|
|
173
|
+
#
|
|
174
|
+
# @return [Boolean]
|
|
175
|
+
# @api public
|
|
176
|
+
# : () -> bool
|
|
177
|
+
def date1904?: () -> bool
|
|
178
|
+
|
|
76
179
|
# Returns the cell value.
|
|
77
180
|
#
|
|
78
181
|
# @return [Object, nil]
|
|
@@ -103,17 +206,19 @@ module Xlsxrb
|
|
|
103
206
|
|
|
104
207
|
# Converts the cell value (numeric serial date or date string) to Date.
|
|
105
208
|
#
|
|
209
|
+
# @param date1904 [Boolean, nil] Whether to use the 1904 date system (defaults to cell's date1904 setting).
|
|
106
210
|
# @return [Date, nil]
|
|
107
211
|
# @api public
|
|
108
|
-
# : () -> Date?
|
|
109
|
-
def to_date: () -> Date?
|
|
212
|
+
# : (?date1904: bool?) -> Date?
|
|
213
|
+
def to_date: (?date1904: bool?) -> Date?
|
|
110
214
|
|
|
111
215
|
# Converts the cell value (numeric serial datetime or datetime string) to Time.
|
|
112
216
|
#
|
|
217
|
+
# @param date1904 [Boolean, nil] Whether to use the 1904 date system (defaults to cell's date1904 setting).
|
|
113
218
|
# @return [Time, nil]
|
|
114
219
|
# @api public
|
|
115
|
-
# : () -> Time?
|
|
116
|
-
def to_time: () -> Time?
|
|
220
|
+
# : (?date1904: bool?) -> Time?
|
|
221
|
+
def to_time: (?date1904: bool?) -> Time?
|
|
117
222
|
|
|
118
223
|
# Pure calculation: converts a 0-based column index to an Excel letter.
|
|
119
224
|
#
|
|
@@ -17,10 +17,11 @@ module Xlsxrb
|
|
|
17
17
|
# @param hidden [Boolean] Whether the column is hidden.
|
|
18
18
|
# @param custom_width [Boolean] Whether custom width flag is set.
|
|
19
19
|
# @param outline_level [Integer, nil] Grouping/outline level.
|
|
20
|
+
# @param style_index [Integer, String, nil] Optional style identifier.
|
|
20
21
|
# @param unmapped_data [Hash] Additional metadata.
|
|
21
22
|
# @param errors [Array<String>, nil] Validation errors.
|
|
22
|
-
# : (index: Integer, ?width: Float | Integer | nil, ?hidden: bool, ?custom_width: bool, ?outline_level: Integer | nil, ?unmapped_data: Hash[untyped, untyped], ?errors: Array[String]?) -> void
|
|
23
|
-
def initialize: (index: Integer, ?width: Float | Integer | nil, ?hidden: bool, ?custom_width: bool, ?outline_level: Integer | nil, ?unmapped_data: Hash[untyped, untyped], ?errors: Array[String]?) -> void
|
|
23
|
+
# : (index: Integer, ?width: Float | Integer | nil, ?hidden: bool, ?custom_width: bool, ?outline_level: Integer | nil, ?style_index: (Integer | String)?, ?unmapped_data: Hash[untyped, untyped], ?errors: Array[String]?) -> void
|
|
24
|
+
def initialize: (index: Integer, ?width: Float | Integer | nil, ?hidden: bool, ?custom_width: bool, ?outline_level: Integer | nil, ?style_index: (Integer | String)?, ?unmapped_data: Hash[untyped, untyped], ?errors: Array[String]?) -> void
|
|
24
25
|
|
|
25
26
|
# Returns whether the column definition is valid according to OOXML specifications.
|
|
26
27
|
#
|
|
@@ -55,6 +55,24 @@ module Xlsxrb
|
|
|
55
55
|
# : () -> Elements::Row?
|
|
56
56
|
def last_row: () -> Elements::Row?
|
|
57
57
|
|
|
58
|
+
# Returns the 1-based index of the first column containing data, or nil.
|
|
59
|
+
#
|
|
60
|
+
# @return [Integer, nil]
|
|
61
|
+
# @api public
|
|
62
|
+
# : () -> Integer?
|
|
63
|
+
def first_column: () -> Integer?
|
|
64
|
+
|
|
65
|
+
alias first_col first_column
|
|
66
|
+
|
|
67
|
+
# Returns the 1-based index of the last column containing data, or nil.
|
|
68
|
+
#
|
|
69
|
+
# @return [Integer, nil]
|
|
70
|
+
# @api public
|
|
71
|
+
# : () -> Integer?
|
|
72
|
+
def last_column: () -> Integer?
|
|
73
|
+
|
|
74
|
+
alias last_col last_column
|
|
75
|
+
|
|
58
76
|
# Returns the raw cell value at the given Excel-style reference (e.g. "A1").
|
|
59
77
|
#
|
|
60
78
|
# @example
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Generated from lib/xlsxrb/elements/image.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Xlsxrb
|
|
4
|
+
module Elements
|
|
5
|
+
# Represents an embedded image anchored to worksheet cells.
|
|
6
|
+
# Coordinates (from_row, from_col, to_row, to_col) are 0-based.
|
|
7
|
+
#
|
|
8
|
+
# @example Access image properties
|
|
9
|
+
# image = sheet.images.first
|
|
10
|
+
# image.filename #=> "image1.png"
|
|
11
|
+
# image.cell_ref #=> "B3"
|
|
12
|
+
# image.content_type #=> "image/png"
|
|
13
|
+
# image.data #=> "\x89PNG..."
|
|
14
|
+
#
|
|
15
|
+
# @api public
|
|
16
|
+
class Image
|
|
17
|
+
MIME_TYPES: untyped
|
|
18
|
+
|
|
19
|
+
# @param filename [String] Target filename (e.g. "image1.png").
|
|
20
|
+
# @param name [String, nil] Image or shape name.
|
|
21
|
+
# @param content_type [String, nil] MIME content type (e.g. "image/png").
|
|
22
|
+
# @param data [String, nil] Raw binary image data.
|
|
23
|
+
# @param from_col [Integer] 0-based starting column index.
|
|
24
|
+
# @param from_row [Integer] 0-based starting row index.
|
|
25
|
+
# @param to_col [Integer, nil] 0-based ending column index (nil for 1-cell anchor).
|
|
26
|
+
# @param to_row [Integer, nil] 0-based ending row index (nil for 1-cell anchor).
|
|
27
|
+
# @param cx [Integer, nil] Extent width in EMUs (English Metric Units).
|
|
28
|
+
# @param cy [Integer, nil] Extent height in EMUs (English Metric Units).
|
|
29
|
+
# @param unmapped_data [Hash] Additional metadata from drawing XML.
|
|
30
|
+
# : (filename: String, ?name: String?, ?content_type: String?, ?data: String?, ?from_col: Integer, ?from_row: Integer, ?to_col: Integer?, ?to_row: Integer?, ?cx: Integer?, ?cy: Integer?, ?unmapped_data: Hash[untyped, untyped]) -> void
|
|
31
|
+
# rubocop:disable Naming/MethodParameterName
|
|
32
|
+
def initialize: (filename: String, ?name: String?, ?content_type: String?, ?data: String?, ?from_col: Integer, ?from_row: Integer, ?to_col: Integer?, ?to_row: Integer?, ?cx: Integer?, ?cy: Integer?, ?unmapped_data: Hash[untyped, untyped]) -> void
|
|
33
|
+
|
|
34
|
+
# Returns the top-left cell coordinate reference string (e.g. "A1").
|
|
35
|
+
#
|
|
36
|
+
# @return [String]
|
|
37
|
+
# @api public
|
|
38
|
+
# : () -> String
|
|
39
|
+
def cell_ref: () -> String
|
|
40
|
+
|
|
41
|
+
alias cell cell_ref
|
|
42
|
+
|
|
43
|
+
alias ref cell_ref
|
|
44
|
+
|
|
45
|
+
# Returns the bottom-right cell coordinate reference string (e.g. "B5"), or nil for 1-cell anchors.
|
|
46
|
+
#
|
|
47
|
+
# @return [String, nil]
|
|
48
|
+
# @api public
|
|
49
|
+
# : () -> String?
|
|
50
|
+
def to_cell_ref: () -> String?
|
|
51
|
+
|
|
52
|
+
# Returns whether this image uses a one-cell anchor.
|
|
53
|
+
#
|
|
54
|
+
# @return [Boolean]
|
|
55
|
+
# @api public
|
|
56
|
+
# : () -> bool
|
|
57
|
+
def one_cell_anchor?: () -> bool
|
|
58
|
+
|
|
59
|
+
# Returns whether this image uses a two-cell anchor.
|
|
60
|
+
#
|
|
61
|
+
# @return [Boolean]
|
|
62
|
+
# @api public
|
|
63
|
+
# : () -> bool
|
|
64
|
+
def two_cell_anchor?: () -> bool
|
|
65
|
+
|
|
66
|
+
# Returns the size of the binary image data in bytes.
|
|
67
|
+
#
|
|
68
|
+
# @return [Integer]
|
|
69
|
+
# @api public
|
|
70
|
+
# : () -> Integer
|
|
71
|
+
def bytesize: () -> Integer
|
|
72
|
+
|
|
73
|
+
# Writes the image data directly to a file on disk.
|
|
74
|
+
#
|
|
75
|
+
# @param path [String] Target file path.
|
|
76
|
+
# @return [Integer] Number of bytes written.
|
|
77
|
+
# @api public
|
|
78
|
+
# : (String path) -> Integer
|
|
79
|
+
def write_to: (String path) -> Integer
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -18,11 +18,12 @@ module Xlsxrb
|
|
|
18
18
|
# @param height [Float, Integer, nil] Row height in points.
|
|
19
19
|
# @param hidden [Boolean] Whether the row is hidden.
|
|
20
20
|
# @param custom_height [Boolean] Whether custom height is set.
|
|
21
|
+
# @param collapsed [Boolean] Whether the row is collapsed.
|
|
21
22
|
# @param outline_level [Integer, nil] Grouping/outline level.
|
|
22
23
|
# @param unmapped_data [Hash] Additional metadata.
|
|
23
24
|
# @param errors [Array<String>, nil] Validation errors.
|
|
24
|
-
# : (index: Integer, ?cells: Array[Elements::Cell], ?height: Float | Integer | nil, ?hidden: bool, ?custom_height: bool, ?outline_level: Integer | nil, ?unmapped_data: Hash[untyped, untyped], ?errors: Array[String]?) -> void
|
|
25
|
-
def initialize: (index: Integer, ?cells: Array[Elements::Cell], ?height: Float | Integer | nil, ?hidden: bool, ?custom_height: bool, ?outline_level: Integer | nil, ?unmapped_data: Hash[untyped, untyped], ?errors: Array[String]?) -> void
|
|
25
|
+
# : (index: Integer, ?cells: Array[Elements::Cell], ?height: Float | Integer | nil, ?hidden: bool, ?custom_height: bool, ?collapsed: bool, ?outline_level: Integer | nil, ?unmapped_data: Hash[untyped, untyped], ?errors: Array[String]?) -> void
|
|
26
|
+
def initialize: (index: Integer, ?cells: Array[Elements::Cell], ?height: Float | Integer | nil, ?hidden: bool, ?custom_height: bool, ?collapsed: bool, ?outline_level: Integer | nil, ?unmapped_data: Hash[untyped, untyped], ?errors: Array[String]?) -> void
|
|
26
27
|
|
|
27
28
|
# Access a cell by 0-based column index, or access row attributes via Symbol.
|
|
28
29
|
#
|
|
@@ -37,6 +38,55 @@ module Xlsxrb
|
|
|
37
38
|
# : (Integer | Symbol col_index) -> untyped
|
|
38
39
|
def []: (Integer | Symbol col_index) -> untyped
|
|
39
40
|
|
|
41
|
+
# Returns a new Row with missing cells padded up to the maximum column index.
|
|
42
|
+
#
|
|
43
|
+
# @return [Elements::Row]
|
|
44
|
+
# @api public
|
|
45
|
+
# : () -> Elements::Row
|
|
46
|
+
def pad_empty_cells: () -> Elements::Row
|
|
47
|
+
|
|
48
|
+
# Returns a coordinate-keyed Hash of cell values (e.g. {"A1" => "value", "B1" => 123}).
|
|
49
|
+
#
|
|
50
|
+
# @param type_cast [Boolean] Whether to coerce date/time serial numbers into Date/Time instances.
|
|
51
|
+
# @return [Hash{String => Object}]
|
|
52
|
+
# @api public
|
|
53
|
+
# : (?type_cast: bool) -> Hash[String, untyped]
|
|
54
|
+
def cells_hash: (?type_cast: bool) -> Hash[String, untyped]
|
|
55
|
+
|
|
56
|
+
# Returns whether the row is hidden.
|
|
57
|
+
#
|
|
58
|
+
# @return [Boolean]
|
|
59
|
+
# @api public
|
|
60
|
+
# : () -> bool
|
|
61
|
+
def hidden?: () -> bool
|
|
62
|
+
|
|
63
|
+
# Returns whether the row is collapsed.
|
|
64
|
+
#
|
|
65
|
+
# @return [Boolean]
|
|
66
|
+
# @api public
|
|
67
|
+
# : () -> bool
|
|
68
|
+
def collapsed?: () -> bool
|
|
69
|
+
|
|
70
|
+
# Returns whether custom height is set.
|
|
71
|
+
#
|
|
72
|
+
# @return [Boolean]
|
|
73
|
+
# @api public
|
|
74
|
+
# : () -> bool
|
|
75
|
+
def custom_height?: () -> bool
|
|
76
|
+
|
|
77
|
+
# Returns a frozen Hash of row attributes.
|
|
78
|
+
#
|
|
79
|
+
# @return [Hash{Symbol => Object}]
|
|
80
|
+
# @api public
|
|
81
|
+
# : () -> Hash[Symbol, untyped]
|
|
82
|
+
def attributes: () -> Hash[Symbol, untyped]
|
|
83
|
+
|
|
84
|
+
# Returns style_index if present in unmapped_data.
|
|
85
|
+
#
|
|
86
|
+
# @return [Integer, nil]
|
|
87
|
+
# : () -> Integer?
|
|
88
|
+
def style_index: () -> Integer?
|
|
89
|
+
|
|
40
90
|
# Iterate over cells in this row.
|
|
41
91
|
#
|
|
42
92
|
# @example
|
|
@@ -85,6 +135,13 @@ module Xlsxrb
|
|
|
85
135
|
# : () -> bool
|
|
86
136
|
def valid?: () -> bool
|
|
87
137
|
|
|
138
|
+
# Returns whether the row contains no cell values (or all cell values are nil or empty strings).
|
|
139
|
+
#
|
|
140
|
+
# @return [Boolean]
|
|
141
|
+
# @api public
|
|
142
|
+
# : () -> bool
|
|
143
|
+
def empty?: () -> bool
|
|
144
|
+
|
|
88
145
|
# Returns the cell at the given 0-based column index, or nil.
|
|
89
146
|
#
|
|
90
147
|
# @param column_index [Integer] 0-based column index.
|
|
@@ -95,10 +152,32 @@ module Xlsxrb
|
|
|
95
152
|
|
|
96
153
|
# Returns cell values as an Array (sparse columns get nil).
|
|
97
154
|
#
|
|
155
|
+
# @param type_cast [Boolean] Whether to coerce date/time serial numbers into Date/Time instances.
|
|
98
156
|
# @return [Array<Object>]
|
|
99
157
|
# @api public
|
|
100
|
-
# : () -> Array[untyped]
|
|
101
|
-
def values: () -> Array[untyped]
|
|
158
|
+
# : (?type_cast: bool) -> Array[untyped]
|
|
159
|
+
def values: (?type_cast: bool) -> Array[untyped]
|
|
160
|
+
|
|
161
|
+
# Returns unparsed raw cell values as an Array (sparse columns get nil).
|
|
162
|
+
#
|
|
163
|
+
# @return [Array<String, nil>]
|
|
164
|
+
# @api public
|
|
165
|
+
# : () -> Array[String?]
|
|
166
|
+
def raw_values: () -> Array[String?]
|
|
167
|
+
|
|
168
|
+
# Returns formatted string representations of cell values as an Array (sparse columns get nil).
|
|
169
|
+
#
|
|
170
|
+
# @return [Array<String, nil>]
|
|
171
|
+
# @api public
|
|
172
|
+
# : () -> Array[String?]
|
|
173
|
+
def formatted_values: () -> Array[String?]
|
|
174
|
+
|
|
175
|
+
# Returns formula expressions without leading '=' as an Array (sparse columns get nil).
|
|
176
|
+
#
|
|
177
|
+
# @return [Array<String, nil>]
|
|
178
|
+
# @api public
|
|
179
|
+
# : () -> Array[String?]
|
|
180
|
+
def formulas: () -> Array[String?]
|
|
102
181
|
|
|
103
182
|
# Returns whether the row index is within valid OOXML range (0..1048575).
|
|
104
183
|
#
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Generated from lib/xlsxrb/elements/styles.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Xlsxrb
|
|
4
|
+
module Elements
|
|
5
|
+
# Represents the workbook stylesheet definitions (fonts, fills, borders, cellXfs, and numFmts).
|
|
6
|
+
# Inherits from Hash for backward compatibility with existing styles hash structures,
|
|
7
|
+
# while providing precomputed O(1) number format classifications.
|
|
8
|
+
#
|
|
9
|
+
# @api public
|
|
10
|
+
class Styles < Hash[untyped, untyped]
|
|
11
|
+
# Initializes the styles container, optionally wrapping an existing styles hash.
|
|
12
|
+
#
|
|
13
|
+
# @param initial_hash [Hash, nil] Initial styles dictionary.
|
|
14
|
+
# : (?Hash[untyped, untyped]? initial_hash) -> void
|
|
15
|
+
def initialize: (?Hash[untyped, untyped]? initial_hash) -> void
|
|
16
|
+
|
|
17
|
+
# Returns the format code string for a given style index.
|
|
18
|
+
#
|
|
19
|
+
# @param style_index [Integer, nil]
|
|
20
|
+
# @return [String, nil]
|
|
21
|
+
# @api public
|
|
22
|
+
# : (Integer? style_index) -> String?
|
|
23
|
+
def number_format: (Integer? style_index) -> String?
|
|
24
|
+
|
|
25
|
+
alias format_code number_format
|
|
26
|
+
|
|
27
|
+
alias format_code_for number_format
|
|
28
|
+
|
|
29
|
+
# Returns the classified format category (:date, :datetime, :time, :number, :text, :general) for a style index.
|
|
30
|
+
#
|
|
31
|
+
# @param style_index [Integer, nil]
|
|
32
|
+
# @return [Symbol, nil]
|
|
33
|
+
# @api public
|
|
34
|
+
# : (Integer? style_index) -> Symbol?
|
|
35
|
+
def format_type: (Integer? style_index) -> Symbol?
|
|
36
|
+
|
|
37
|
+
alias classification_for format_type
|
|
38
|
+
|
|
39
|
+
# Returns whether the style index represents a date, datetime, or time pattern.
|
|
40
|
+
#
|
|
41
|
+
# @param style_index [Integer, nil]
|
|
42
|
+
# @return [Boolean]
|
|
43
|
+
# @api public
|
|
44
|
+
# : (Integer? style_index) -> bool
|
|
45
|
+
def date_format?: (Integer? style_index) -> bool
|
|
46
|
+
|
|
47
|
+
# Returns whether the style index represents a datetime pattern.
|
|
48
|
+
#
|
|
49
|
+
# @param style_index [Integer, nil]
|
|
50
|
+
# @return [Boolean]
|
|
51
|
+
# @api public
|
|
52
|
+
# : (Integer? style_index) -> bool
|
|
53
|
+
def datetime_format?: (Integer? style_index) -> bool
|
|
54
|
+
|
|
55
|
+
# Returns whether the style index represents a time pattern.
|
|
56
|
+
#
|
|
57
|
+
# @param style_index [Integer, nil]
|
|
58
|
+
# @return [Boolean]
|
|
59
|
+
# @api public
|
|
60
|
+
# : (Integer? style_index) -> bool
|
|
61
|
+
def time_format?: (Integer? style_index) -> bool
|
|
62
|
+
|
|
63
|
+
# Returns whether the style index represents a date-only pattern.
|
|
64
|
+
#
|
|
65
|
+
# @param style_index [Integer, nil]
|
|
66
|
+
# @return [Boolean]
|
|
67
|
+
# @api public
|
|
68
|
+
# : (Integer? style_index) -> bool
|
|
69
|
+
def date_only_format?: (Integer? style_index) -> bool
|
|
70
|
+
|
|
71
|
+
# Precomputes format code and type classification lookups for all cellXfs.
|
|
72
|
+
#
|
|
73
|
+
# @return [self]
|
|
74
|
+
# @api public
|
|
75
|
+
# : () -> self
|
|
76
|
+
def precompute!: () -> self
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -62,6 +62,25 @@ module Xlsxrb
|
|
|
62
62
|
def members: () -> [ :code ]
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
+
# Represents a formatted text run within a rich text string.
|
|
66
|
+
#
|
|
67
|
+
# @example
|
|
68
|
+
# run = Elements::RichTextRun.new(text: "Hello", font: { bold: true })
|
|
69
|
+
#
|
|
70
|
+
# @api public
|
|
71
|
+
class RichTextRun < Data
|
|
72
|
+
attr_reader text(): untyped
|
|
73
|
+
|
|
74
|
+
attr_reader font(): untyped
|
|
75
|
+
|
|
76
|
+
def self.new: (untyped text, untyped font) -> instance
|
|
77
|
+
| (text: untyped, font: untyped) -> instance
|
|
78
|
+
|
|
79
|
+
def self.members: () -> [ :text, :font ]
|
|
80
|
+
|
|
81
|
+
def members: () -> [ :text, :font ]
|
|
82
|
+
end
|
|
83
|
+
|
|
65
84
|
# Represents a rich text string with multiple formatting runs.
|
|
66
85
|
#
|
|
67
86
|
# @example
|
|
@@ -78,5 +97,29 @@ module Xlsxrb
|
|
|
78
97
|
|
|
79
98
|
def members: () -> [ :runs ]
|
|
80
99
|
end
|
|
100
|
+
|
|
101
|
+
# Represents a worksheet hyperlink with an optional target URL, display text, tooltip (ScreenTip), and internal location.
|
|
102
|
+
#
|
|
103
|
+
# @example Create a hyperlink
|
|
104
|
+
# link = Elements::Hyperlink.new(url: "https://example.com", tooltip: "Visit website")
|
|
105
|
+
#
|
|
106
|
+
# @api public
|
|
107
|
+
# rubocop:disable Lint/DataDefineOverride -- :display represents the hyperlink display text attribute in OOXML
|
|
108
|
+
class Hyperlink < Data
|
|
109
|
+
attr_reader url(): untyped
|
|
110
|
+
|
|
111
|
+
attr_reader display(): untyped
|
|
112
|
+
|
|
113
|
+
attr_reader tooltip(): untyped
|
|
114
|
+
|
|
115
|
+
attr_reader location(): untyped
|
|
116
|
+
|
|
117
|
+
def self.new: (untyped url, untyped display, untyped tooltip, untyped location) -> instance
|
|
118
|
+
| (url: untyped, display: untyped, tooltip: untyped, location: untyped) -> instance
|
|
119
|
+
|
|
120
|
+
def self.members: () -> [ :url, :display, :tooltip, :location ]
|
|
121
|
+
|
|
122
|
+
def members: () -> [ :url, :display, :tooltip, :location ]
|
|
123
|
+
end
|
|
81
124
|
end
|
|
82
125
|
end
|
|
@@ -17,8 +17,10 @@ module Xlsxrb
|
|
|
17
17
|
# @param styles [Hash] Styles definition.
|
|
18
18
|
# @param unmapped_data [Hash] Additional metadata for round-tripping.
|
|
19
19
|
# @param errors [Array<String>, nil] Validation errors.
|
|
20
|
-
#
|
|
21
|
-
|
|
20
|
+
# @param defined_names [Array<Hash>, nil] Defined names list.
|
|
21
|
+
# @param date1904 [Boolean] Whether the workbook uses the 1904 date system.
|
|
22
|
+
# : (?sheets: Array[Elements::Worksheet | StreamSheet], ?shared_strings: Array[String], ?styles: Hash[untyped, untyped], ?unmapped_data: Hash[untyped, untyped], ?errors: Array[String]?, ?defined_names: Array[Hash[Symbol, untyped]]?, ?date1904: bool) -> void
|
|
23
|
+
def initialize: (?sheets: Array[Elements::Worksheet | StreamSheet], ?shared_strings: Array[String], ?styles: Hash[untyped, untyped], ?unmapped_data: Hash[untyped, untyped], ?errors: Array[String]?, ?defined_names: Array[Hash[Symbol, untyped]]?, ?date1904: bool) -> void
|
|
22
24
|
|
|
23
25
|
# Iterate over worksheets.
|
|
24
26
|
#
|
|
@@ -43,6 +45,26 @@ module Xlsxrb
|
|
|
43
45
|
# : () -> bool
|
|
44
46
|
def valid?: () -> bool
|
|
45
47
|
|
|
48
|
+
# Returns whether the workbook uses the 1904 date system.
|
|
49
|
+
#
|
|
50
|
+
# @return [Boolean]
|
|
51
|
+
# @api public
|
|
52
|
+
# : () -> bool
|
|
53
|
+
def date1904?: () -> bool
|
|
54
|
+
|
|
55
|
+
# Returns the defined name matching name (and optionally sheet), or nil.
|
|
56
|
+
#
|
|
57
|
+
# @example
|
|
58
|
+
# wb.defined_name("SalesTotal")
|
|
59
|
+
# wb.defined_name("Print_Area", sheet: "Sheet1")
|
|
60
|
+
#
|
|
61
|
+
# @param name [String] The defined name.
|
|
62
|
+
# @param sheet [String, Integer, nil] Optional sheet name or 0-based index.
|
|
63
|
+
# @return [Hash[Symbol, untyped], nil]
|
|
64
|
+
# @api public
|
|
65
|
+
# : (String name, ?sheet: (String | Integer)?) -> Hash[Symbol, untyped]?
|
|
66
|
+
def defined_name: (String name, ?sheet: (String | Integer)?) -> Hash[Symbol, untyped]?
|
|
67
|
+
|
|
46
68
|
# Returns the worksheet at the given 0-based index or by name.
|
|
47
69
|
#
|
|
48
70
|
# @example
|
|
@@ -57,6 +79,33 @@ module Xlsxrb
|
|
|
57
79
|
|
|
58
80
|
alias [] sheet
|
|
59
81
|
|
|
82
|
+
# Returns the formatted string representation of a cell's value in the specified sheet.
|
|
83
|
+
#
|
|
84
|
+
# @param sheet_identifier [Integer, String, untyped] 0-based index or sheet name.
|
|
85
|
+
# @param ref_or_row [String, Symbol, Integer] Cell reference (e.g. "A1") or 0-based row index.
|
|
86
|
+
# @param col [Integer, nil] Optional 0-based column index.
|
|
87
|
+
# @return [String, nil]
|
|
88
|
+
# @api public
|
|
89
|
+
# : (Integer | String | untyped sheet_identifier, String | Symbol | Integer ref_or_row, ?Integer? col) -> String?
|
|
90
|
+
def formatted_value: (Integer | String | untyped sheet_identifier, String | Symbol | Integer ref_or_row, ?Integer? col) -> String?
|
|
91
|
+
|
|
92
|
+
# Returns all embedded images across all worksheets.
|
|
93
|
+
#
|
|
94
|
+
# @return [Array<Elements::Image>]
|
|
95
|
+
# @api public
|
|
96
|
+
# : () -> Array[Elements::Image]
|
|
97
|
+
def images: () -> Array[Elements::Image]
|
|
98
|
+
|
|
99
|
+
# Returns all images anchored at a specific cell in the given worksheet.
|
|
100
|
+
#
|
|
101
|
+
# @param sheet_identifier [Integer, String, untyped] Sheet index or sheet name.
|
|
102
|
+
# @param ref_or_row [String, Symbol, Integer] Cell reference (e.g. "A1") or 0-based row index.
|
|
103
|
+
# @param col [Integer, nil] Optional 0-based column index.
|
|
104
|
+
# @return [Array<Elements::Image>]
|
|
105
|
+
# @api public
|
|
106
|
+
# : (Integer | String | untyped sheet_identifier, String | Symbol | Integer ref_or_row, ?Integer? col) -> Array[Elements::Image]
|
|
107
|
+
def images_at: (Integer | String | untyped sheet_identifier, String | Symbol | Integer ref_or_row, ?Integer? col) -> Array[Elements::Image]
|
|
108
|
+
|
|
60
109
|
# Loads all sheets into memory, returning an Elements::Workbook where every
|
|
61
110
|
# worksheet is a fully-parsed Elements::Worksheet supporting coordinate random access.
|
|
62
111
|
#
|