xlsxrb 0.1.17 → 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.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +93 -1
  3. data/README.md +79 -19
  4. data/lib/ruby_lsp/xlsxrb/completion_listener.rb +31 -61
  5. data/lib/xlsxrb/chart_builder.rb +595 -113
  6. data/lib/xlsxrb/dsl_helpers.rb +72 -20
  7. data/lib/xlsxrb/elements/cell.rb +243 -56
  8. data/lib/xlsxrb/elements/column.rb +94 -5
  9. data/lib/xlsxrb/elements/coordinate_access.rb +108 -10
  10. data/lib/xlsxrb/elements/image.rb +81 -15
  11. data/lib/xlsxrb/elements/metadata.rb +2733 -0
  12. data/lib/xlsxrb/elements/row.rb +130 -46
  13. data/lib/xlsxrb/elements/styles.rb +184 -76
  14. data/lib/xlsxrb/elements/types.rb +242 -7
  15. data/lib/xlsxrb/elements/workbook.rb +171 -82
  16. data/lib/xlsxrb/elements/worksheet.rb +598 -102
  17. data/lib/xlsxrb/elements.rb +1 -0
  18. data/lib/xlsxrb/ooxml/reader/listeners/core_listeners.rb +12 -4
  19. data/lib/xlsxrb/ooxml/reader/listeners/drawing_listeners.rb +7 -2
  20. data/lib/xlsxrb/ooxml/reader/listeners/feature_listeners.rb +264 -17
  21. data/lib/xlsxrb/ooxml/reader/listeners/style_listeners.rb +17 -3
  22. data/lib/xlsxrb/ooxml/reader.rb +4 -0
  23. data/lib/xlsxrb/ooxml/styles_parser.rb +10 -3
  24. data/lib/xlsxrb/ooxml/workbook_writer.rb +90 -36
  25. data/lib/xlsxrb/ooxml/worksheet_parser.rb +2 -2
  26. data/lib/xlsxrb/ooxml/worksheet_writer.rb +64 -19
  27. data/lib/xlsxrb/ooxml/writer/drawing_xml.rb +5 -2
  28. data/lib/xlsxrb/ooxml/writer/features_xml.rb +26 -5
  29. data/lib/xlsxrb/ooxml/writer/styles_xml.rb +19 -9
  30. data/lib/xlsxrb/ooxml/writer.rb +22 -6
  31. data/lib/xlsxrb/ooxml/zip_generator.rb +2 -0
  32. data/lib/xlsxrb/ooxml/zip_reader.rb +47 -10
  33. data/lib/xlsxrb/stream_row.rb +97 -18
  34. data/lib/xlsxrb/stream_sheet.rb +706 -190
  35. data/lib/xlsxrb/stream_writer.rb +1893 -374
  36. data/lib/xlsxrb/style_builder.rb +774 -111
  37. data/lib/xlsxrb/utils.rb +66 -106
  38. data/lib/xlsxrb/version.rb +1 -1
  39. data/lib/xlsxrb/workbook_builder.rb +380 -83
  40. data/lib/xlsxrb/worksheet_builder.rb +1210 -233
  41. data/lib/xlsxrb.rb +1266 -326
  42. data/sig/generated/xlsxrb/chart_builder.rbs +319 -90
  43. data/sig/generated/xlsxrb/dsl_helpers.rbs +20 -2
  44. data/sig/generated/xlsxrb/elements/cell.rbs +92 -20
  45. data/sig/generated/xlsxrb/elements/column.rbs +61 -2
  46. data/sig/generated/xlsxrb/elements/coordinate_access.rbs +49 -7
  47. data/sig/generated/xlsxrb/elements/image.rbs +30 -8
  48. data/sig/generated/xlsxrb/elements/metadata.rbs +1587 -0
  49. data/sig/generated/xlsxrb/elements/row.rbs +61 -21
  50. data/sig/generated/xlsxrb/elements/styles.rbs +96 -58
  51. data/sig/generated/xlsxrb/elements/types.rbs +27 -0
  52. data/sig/generated/xlsxrb/elements/workbook.rbs +63 -52
  53. data/sig/generated/xlsxrb/elements/worksheet.rbs +192 -51
  54. data/sig/generated/xlsxrb/ooxml/reader/listeners/feature_listeners.rbs +61 -0
  55. data/sig/generated/xlsxrb/ooxml/reader.rbs +3 -0
  56. data/sig/generated/xlsxrb/ooxml/workbook_writer.rbs +1 -1
  57. data/sig/generated/xlsxrb/ooxml/worksheet_writer.rbs +1 -1
  58. data/sig/generated/xlsxrb/ooxml/writer.rbs +3 -0
  59. data/sig/generated/xlsxrb/ooxml/zip_generator.rbs +2 -0
  60. data/sig/generated/xlsxrb/ooxml/zip_reader.rbs +2 -2
  61. data/sig/generated/xlsxrb/stream_row.rbs +48 -14
  62. data/sig/generated/xlsxrb/stream_sheet.rbs +324 -115
  63. data/sig/generated/xlsxrb/stream_writer.rbs +1068 -255
  64. data/sig/generated/xlsxrb/style_builder.rbs +389 -79
  65. data/sig/generated/xlsxrb/utils.rbs +34 -18
  66. data/sig/generated/xlsxrb/workbook_builder.rbs +234 -34
  67. data/sig/generated/xlsxrb/worksheet_builder.rbs +628 -126
  68. data/sig/generated/xlsxrb.rbs +257 -49
  69. 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,22 +141,34 @@ 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
 
@@ -169,16 +182,19 @@ module Xlsxrb
169
182
  # @example Shift formula with absolute references
170
183
  # Xlsxrb::Utils.expand_formula("$A$1+A2", from_ref: "B2", to_ref: "B4") #=> "$A$1+A4"
171
184
  #
172
- # @param formula [String] Formula expression to expand.
185
+ # @deprecated Use {Xlsxrb.expand_formula} instead. Will be removed in 0.2.0.
186
+ # @param formula [String, nil] Formula expression to expand.
173
187
  # @param from_ref [String, nil] Master cell reference (e.g. "B2").
174
188
  # @param to_ref [String, nil] Target cell reference (e.g. "B3").
175
189
  # @param row_delta [Integer, nil] Row shift amount (positive = down, negative = up).
176
- # @param col_delta [Integer, nil] Column shift amount (positive = right, negative = left).
190
+ # @param column_delta [Integer, nil] Column shift amount (positive = right, negative = left).
191
+ # @param col_delta [Integer, nil] Deprecated alias for column_delta.
177
192
  # @return [String, nil] Expanded formula expression.
178
- # @api public
179
- # : (String? formula, ?from_ref: String?, ?to_ref: String?, ?row_delta: Integer?, ?col_delta: Integer?) -> String?
180
- def self.expand_formula: (String? formula, ?from_ref: String?, ?to_ref: String?, ?row_delta: Integer?, ?col_delta: Integer?) -> String?
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?
181
195
 
182
- alias self.serial_to_datetime self.serial_to_time
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
183
199
  end
184
200
  end
@@ -15,9 +15,21 @@ module Xlsxrb
15
15
  # @api public
16
16
  class WorkbookBuilder
17
17
  # @param strict_excel_mode [Boolean] Whether to enforce Microsoft Excel specifications.
18
+ # @param escape_formulas [Boolean] Whether to treat strings starting with formula prefixes as plain text.
18
19
  # @param default_font [Hash, nil] Optional default font options (e.g. `{ name: "Arial", size: 12 }`).
19
- # : (?strict_excel_mode: bool, ?default_font: untyped?) -> void
20
- def initialize: (?strict_excel_mode: bool, ?default_font: untyped?) -> void
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
21
33
 
22
34
  # Sets or configures the workbook-wide default font.
23
35
  #
@@ -29,61 +41,164 @@ module Xlsxrb
29
41
  # : (?String | Hash[Symbol, untyped]? name, ?Float | Integer | nil size, **untyped opts) -> void
30
42
  def default_font: (?String | Hash[Symbol, untyped]? name, ?Float | Integer | nil size, **untyped opts) -> void
31
43
 
44
+ # @deprecated Use {#default_font} instead. Will be removed in 0.2.0.
32
45
  alias set_default_font default_font
33
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
+
34
116
  # Gets or sets the active worksheet tab in the workbook window.
35
117
  #
118
+ # @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#active_sheet=} instead.
36
119
  # @param name_or_index [String, Symbol, Integer, nil] Sheet name or 0-based sheet index.
37
120
  # @return [String, Symbol, Integer, nil]
38
121
  # @api public
39
122
  # : (?String | Symbol | Integer | nil name_or_index) -> (String | Symbol | Integer | nil)
40
123
  def active_sheet: (?String | Symbol | Integer | nil name_or_index) -> (String | Symbol | Integer | nil)
41
124
 
42
- alias active_sheet= active_sheet
43
-
125
+ # @deprecated Use {#active_sheet} instead. Will be removed in 0.2.0.
44
126
  alias active_tab active_sheet
45
127
 
46
- alias active_tab= active_sheet
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=
47
137
 
48
138
  # Gets or sets the first sheet tab visible in the sheet tab scroll area.
49
139
  #
140
+ # @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#first_sheet=} instead.
50
141
  # @param name_or_index [String, Symbol, Integer, nil] Sheet name or 0-based sheet index.
51
142
  # @return [String, Symbol, Integer, nil]
52
143
  # @api public
53
144
  # : (?String | Symbol | Integer | nil name_or_index) -> (String | Symbol | Integer | nil)
54
145
  def first_sheet: (?String | Symbol | Integer | nil name_or_index) -> (String | Symbol | Integer | nil)
55
146
 
56
- alias first_sheet= first_sheet
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
57
153
 
58
154
  # Gets or sets whether sheet tabs are visible in the workbook window.
59
155
  #
156
+ # @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#show_sheet_tabs=} instead.
60
157
  # @param visible [Boolean, nil]
61
158
  # @return [Boolean, nil]
62
159
  # @api public
63
160
  # : (?bool? visible) -> bool?
64
161
  def show_sheet_tabs: (?bool? visible) -> bool?
65
162
 
66
- alias show_sheet_tabs= show_sheet_tabs
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?
67
169
 
68
170
  # Gets or sets the ratio between the sheet tabs bar and the horizontal scroll bar (0-1000).
69
171
  #
172
+ # @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#tab_ratio=} instead.
70
173
  # @param ratio [Integer, nil]
71
174
  # @return [Integer, nil]
72
175
  # @api public
73
176
  # : (?Integer? ratio) -> Integer?
74
177
  def tab_ratio: (?Integer? ratio) -> Integer?
75
178
 
76
- alias tab_ratio= tab_ratio
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?
77
185
 
78
186
  # Gets or sets the internal code name of the workbook.
79
187
  #
188
+ # @deprecated Calling with arguments is deprecated and will be removed in 0.2.0. Use {#code_name=} instead.
80
189
  # @param name [String, Symbol, nil] The code name.
81
190
  # @return [String, nil]
82
191
  # @api public
83
192
  # : (?String | Symbol | nil name) -> String?
84
193
  def code_name: (?String | Symbol | nil name) -> String?
85
194
 
86
- alias code_name= code_name
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?
87
202
 
88
203
  # Sets a workbook-level property.
89
204
  #
@@ -95,8 +210,23 @@ module Xlsxrb
95
210
  # @param value [String, Integer, Boolean] Property value.
96
211
  # @return [void]
97
212
  # @api public
98
- # : (Symbol name, String | Integer | bool value) -> (String | Integer | bool)
99
- def workbook_property: (Symbol name, String | Integer | bool value) -> (String | Integer | bool)
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
100
230
 
101
231
  # Returns the list of worksheet names added to this workbook so far.
102
232
  #
@@ -108,54 +238,91 @@ module Xlsxrb
108
238
  # Adds a new worksheet to the workbook.
109
239
  #
110
240
  # @param name [String, nil] Sheet name (max 31 chars, no forbidden chars `[ ] * ? / \ :`).
111
- # @param opts [Hash] Sheet properties.
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.
112
246
  # @yield [sheet_builder]
113
247
  # @yieldparam sheet_builder [Xlsxrb::WorksheetBuilder]
114
248
  # @return [Elements::Worksheet]
115
249
  # @raise [ArgumentError] If sheet name violates Excel limits in strict mode.
116
250
  # @api public
117
- # : (?String? name, **untyped opts) ?{ (WorksheetBuilder) -> void } -> untyped
118
- def sheet: (?String? name, **untyped opts) ?{ (WorksheetBuilder) -> void } -> untyped
119
-
120
- alias [] sheet
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
121
253
 
122
- # Adds a defined name (named range or formula constant) to the workbook.
254
+ # Accesses or defines a worksheet by name.
123
255
  #
124
- # @param name [String] Defined name (e.g. "TaxRate").
125
- # @param value [String] Formula expression or range reference (e.g. "Sheet1!$B$2").
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
262
+
126
263
  # Adds a defined name (named range or formula) to the workbook.
127
264
  # Bare cell references and coordinate keywords are automatically formatted with sheet quotes and absolute $ references.
128
265
  #
129
266
  # @param name [String] Defined name identifier.
130
267
  # @param value [Object, nil] Value or formula expression.
131
- # @param sheet [String, nil] Optional sheet name for sheet-scoped defined names.
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).
132
270
  # @param hidden [Boolean] Whether the defined name is hidden from Excel's UI.
133
- # @param col [Integer, String, nil] Column index or letter for coordinate-based reference.
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.
134
275
  # @param rows [Integer, Range, nil] Row or row range (1-based) for coordinate-based reference.
135
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.
136
279
  # @return [void]
137
280
  # @api public
138
- # : (String name, ?untyped value, ?sheet: String?, ?hidden: bool, ?col: untyped, ?rows: untyped, ?range: untyped, ?ref_sheet: String?, ?local: bool) -> void
139
- def defined_name: (String name, ?untyped value, ?sheet: String?, ?hidden: bool, ?col: untyped, ?rows: untyped, ?range: untyped, ?ref_sheet: String?, ?local: bool) -> void
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
140
283
 
141
- # Sets the print area for a sheet.
284
+ # Returns workbook-level defined names.
142
285
  #
143
- # @param range [String] Cell range (e.g. "A1:G50").
286
+ # @return [Array<Elements::DefinedName>]
287
+ # @api public
288
+ # : () -> Array[Elements::DefinedName]
289
+ def defined_names: () -> Array[Elements::DefinedName]
290
+
291
+ # Sets or gets the print area for a sheet.
292
+ #
293
+ # @param range [String, Object, nil] Cell range (e.g. "A1:G50").
144
294
  # @param sheet [String, nil] Target sheet name (defaults to latest or "Sheet1").
145
- # @return [void]
295
+ # @return [String, nil, void]
146
296
  # @api public
147
- # : (String range, ?sheet: String?) -> void
148
- def print_area: (String range, ?sheet: String?) -> void
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]
304
+ # @api public
305
+ # : (String? range) -> String?
306
+ def print_area=: (String? range) -> String?
149
307
 
150
308
  # Sets repeating print titles (rows and/or columns) for pagination.
151
309
  #
152
310
  # @param rows [String, nil] Repeating row range (e.g. "1:2").
153
- # @param cols [String, nil] Repeating column range (e.g. "A:B").
311
+ # @param columns [String, nil] Repeating column range (e.g. "A:B").
312
+ # @param cols [String, nil] Deprecated alias for columns.
154
313
  # @param sheet [String, nil] Target sheet name.
155
314
  # @return [void]
156
315
  # @api public
157
- # : (?rows: String?, ?cols: String?, ?sheet: String?) -> void
158
- 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])
159
326
 
160
327
  # Sets repeating title rows for pagination on the target or active sheet.
161
328
  #
@@ -183,11 +350,23 @@ module Xlsxrb
183
350
  # : (Integer | String first, ?(Integer | String)? last, ?sheet: String?) -> void
184
351
  def repeat_columns: (Integer | String first, ?(Integer | String)? last, ?sheet: String?) -> void
185
352
 
186
- # Sets workbook structure and window protection.
353
+ # Sets or returns workbook structure and window protection.
187
354
  #
188
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]
189
364
  # @return [void]
190
365
  # @api public
366
+ # : (untyped opts) -> void
367
+ def workbook_protection=: (untyped opts) -> void
368
+
369
+ # @deprecated Use {#workbook_protection} instead.
191
370
  # : (**String | Integer | bool | nil opts) -> void
192
371
  def protect_workbook: (**String | Integer | bool | nil opts) -> void
193
372
 
@@ -200,6 +379,13 @@ module Xlsxrb
200
379
  # : (Symbol name, String | Integer | Time value) -> void
201
380
  def core_property: (Symbol name, String | Integer | Time value) -> void
202
381
 
382
+ # Returns core document properties.
383
+ #
384
+ # @return [Elements::CoreProperties]
385
+ # @api public
386
+ # : () -> Elements::CoreProperties
387
+ def core_properties: () -> Elements::CoreProperties
388
+
203
389
  # Sets an extended application metadata property.
204
390
  #
205
391
  # @param name [Symbol] Application property name (:company, :manager, :app_version, etc.).
@@ -209,6 +395,13 @@ module Xlsxrb
209
395
  # : (Symbol name, String | Integer | Time value) -> void
210
396
  def app_property: (Symbol name, String | Integer | Time value) -> void
211
397
 
398
+ # Returns application document properties.
399
+ #
400
+ # @return [Elements::AppProperties]
401
+ # @api public
402
+ # : () -> Elements::AppProperties
403
+ def app_properties: () -> Elements::AppProperties
404
+
212
405
  # Sets multiple core, app, and/or custom properties simultaneously.
213
406
  #
214
407
  # @param core [Hash{Symbol => Object}, nil] Core properties map.
@@ -229,6 +422,13 @@ module Xlsxrb
229
422
  # : (String name, String | Integer | Float | bool | Time value, ?type: ::Symbol) -> void
230
423
  def custom_property: (String name, String | Integer | Float | bool | Time value, ?type: ::Symbol) -> void
231
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
+
232
432
  # Builds and returns the compiled {Elements::Workbook}.
233
433
  #
234
434
  # @return [Elements::Workbook]
@@ -248,7 +448,7 @@ module Xlsxrb
248
448
  # : (untyped sheets) -> (::Array[untyped | ::Hash[untyped, untyped]] | ::Array[untyped])
249
449
  def process_styles: (untyped sheets) -> (::Array[untyped | ::Hash[untyped, untyped]] | ::Array[untyped])
250
450
 
251
- # : (untyped writer) -> { fonts: untyped, fills: untyped, borders: untyped, xf_entries: untyped, num_fmts: untyped }
252
- def extract_styles_from_writer: (untyped writer) -> { fonts: untyped, fills: untyped, borders: untyped, xf_entries: untyped, num_fmts: untyped }
451
+ # : (untyped writer) -> Hash[Symbol, untyped]
452
+ def extract_styles_from_writer: (untyped writer) -> Hash[Symbol, untyped]
253
453
  end
254
454
  end