xlsxrb 0.1.17 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +256 -1
  3. data/README.md +111 -28
  4. data/lib/ruby_lsp/xlsxrb/completion_listener.rb +439 -139
  5. data/lib/xlsxrb/chart_builder.rb +540 -193
  6. data/lib/xlsxrb/dsl_helpers.rb +178 -73
  7. data/lib/xlsxrb/elements/cell.rb +197 -130
  8. data/lib/xlsxrb/elements/column.rb +88 -7
  9. data/lib/xlsxrb/elements/coordinate_access.rb +86 -59
  10. data/lib/xlsxrb/elements/image.rb +18 -19
  11. data/lib/xlsxrb/elements/metadata.rb +2379 -0
  12. data/lib/xlsxrb/elements/row.rb +84 -118
  13. data/lib/xlsxrb/elements/styles.rb +140 -90
  14. data/lib/xlsxrb/elements/types.rb +164 -22
  15. data/lib/xlsxrb/elements/workbook.rb +122 -140
  16. data/lib/xlsxrb/elements/worksheet.rb +451 -226
  17. data/lib/xlsxrb/elements.rb +1 -0
  18. data/lib/xlsxrb/ooxml/reader/listeners/core_listeners.rb +16 -5
  19. data/lib/xlsxrb/ooxml/reader/listeners/drawing_listeners.rb +14 -9
  20. data/lib/xlsxrb/ooxml/reader/listeners/feature_listeners.rb +296 -34
  21. data/lib/xlsxrb/ooxml/reader/listeners/style_listeners.rb +17 -3
  22. data/lib/xlsxrb/ooxml/reader.rb +52 -50
  23. data/lib/xlsxrb/ooxml/styles_parser.rb +36 -5
  24. data/lib/xlsxrb/ooxml/utils.rb +2 -2
  25. data/lib/xlsxrb/ooxml/workbook_parser.rb +0 -1
  26. data/lib/xlsxrb/ooxml/workbook_writer.rb +242 -109
  27. data/lib/xlsxrb/ooxml/worksheet_parser.rb +63 -31
  28. data/lib/xlsxrb/ooxml/worksheet_writer.rb +119 -56
  29. data/lib/xlsxrb/ooxml/writer/drawing_xml.rb +33 -13
  30. data/lib/xlsxrb/ooxml/writer/features_xml.rb +75 -15
  31. data/lib/xlsxrb/ooxml/writer/styles_xml.rb +18 -8
  32. data/lib/xlsxrb/ooxml/writer.rb +124 -44
  33. data/lib/xlsxrb/ooxml/xml_parser.rb +78 -5
  34. data/lib/xlsxrb/ooxml/zip_generator.rb +2 -0
  35. data/lib/xlsxrb/ooxml/zip_reader.rb +112 -25
  36. data/lib/xlsxrb/ooxml/zip_writer.rb +119 -30
  37. data/lib/xlsxrb/stream_row.rb +56 -81
  38. data/lib/xlsxrb/stream_sheet.rb +542 -273
  39. data/lib/xlsxrb/stream_writer.rb +1536 -870
  40. data/lib/xlsxrb/style_builder.rb +667 -221
  41. data/lib/xlsxrb/version.rb +1 -1
  42. data/lib/xlsxrb/workbook_builder.rb +406 -143
  43. data/lib/xlsxrb/worksheet_builder.rb +1009 -900
  44. data/lib/xlsxrb.rb +1179 -1056
  45. data/sig/generated/xlsxrb/chart_builder.rbs +385 -159
  46. data/sig/generated/xlsxrb/dsl_helpers.rbs +81 -15
  47. data/sig/generated/xlsxrb/elements/cell.rbs +78 -70
  48. data/sig/generated/xlsxrb/elements/column.rbs +55 -3
  49. data/sig/generated/xlsxrb/elements/coordinate_access.rbs +35 -29
  50. data/sig/generated/xlsxrb/elements/image.rbs +7 -11
  51. data/sig/generated/xlsxrb/elements/metadata.rbs +1574 -0
  52. data/sig/generated/xlsxrb/elements/row.rbs +39 -42
  53. data/sig/generated/xlsxrb/elements/styles.rbs +66 -66
  54. data/sig/generated/xlsxrb/elements/types.rbs +27 -0
  55. data/sig/generated/xlsxrb/elements/workbook.rbs +46 -99
  56. data/sig/generated/xlsxrb/elements/worksheet.rbs +121 -96
  57. data/sig/generated/xlsxrb/ooxml/reader/listeners/feature_listeners.rbs +61 -4
  58. data/sig/generated/xlsxrb/ooxml/reader.rbs +2 -2
  59. data/sig/generated/xlsxrb/ooxml/styles_parser.rbs +1 -1
  60. data/sig/generated/xlsxrb/ooxml/utils.rbs +3 -3
  61. data/sig/generated/xlsxrb/ooxml/workbook_writer.rbs +13 -1
  62. data/sig/generated/xlsxrb/ooxml/worksheet_parser.rbs +16 -0
  63. data/sig/generated/xlsxrb/ooxml/worksheet_writer.rbs +6 -4
  64. data/sig/generated/xlsxrb/ooxml/writer/features_xml.rbs +7 -0
  65. data/sig/generated/xlsxrb/ooxml/writer.rbs +22 -13
  66. data/sig/generated/xlsxrb/ooxml/xml_parser.rbs +70 -0
  67. data/sig/generated/xlsxrb/ooxml/zip_generator.rbs +2 -0
  68. data/sig/generated/xlsxrb/ooxml/zip_reader.rbs +24 -9
  69. data/sig/generated/xlsxrb/ooxml/zip_writer.rbs +26 -1
  70. data/sig/generated/xlsxrb/stream_row.rbs +32 -33
  71. data/sig/generated/xlsxrb/stream_sheet.rbs +233 -181
  72. data/sig/generated/xlsxrb/stream_writer.rbs +961 -667
  73. data/sig/generated/xlsxrb/style_builder.rbs +402 -128
  74. data/sig/generated/xlsxrb/workbook_builder.rbs +223 -71
  75. data/sig/generated/xlsxrb/worksheet_builder.rbs +579 -453
  76. data/sig/generated/xlsxrb.rbs +205 -144
  77. data/sig/rexml.rbs +8 -0
  78. metadata +5 -5
  79. data/lib/xlsxrb/utils.rb +0 -291
  80. data/sig/generated/xlsxrb/utils.rbs +0 -184
@@ -13,9 +13,7 @@ module Xlsxrb
13
13
 
14
14
  INTEGER_STRINGS: untyped
15
15
 
16
- attr_accessor escape_formulas: untyped
17
-
18
- def initialize: (untyped io, ?date1904: untyped, ?escape_formulas: untyped) -> untyped
16
+ def initialize: (untyped io, ?date1904: untyped) -> untyped
19
17
 
20
18
  def set_column_style: (untyped col_index, untyped style_id) -> untyped
21
19
 
@@ -36,7 +34,7 @@ module Xlsxrb
36
34
 
37
35
  # Write the worksheet footer. Call once after all rows.
38
36
  # Options for post-sheetData elements (in OOXML order):
39
- def finish: (?drawing_rid: untyped, ?picture_rid: untyped, ?sheet_protection: untyped, ?protected_ranges: untyped, ?auto_filter: untyped, ?filter_columns: untyped, ?sort_state: untyped, ?merge_cells: untyped, ?conditional_formats: untyped, ?data_validations: untyped, ?hyperlinks: untyped, ?print_options: untyped, ?page_margins: untyped, ?page_setup: untyped, ?header_footer: untyped, ?row_breaks: untyped, ?col_breaks: untyped, ?cell_watches: untyped, ?ignored_errors: untyped, ?tables: untyped, ?table_start_rid: untyped, ?legacy_drawing_rid: untyped, ?sparkline_groups: untyped, ?phonetic_pr: untyped, ?sheet_calc_pr: untyped) -> untyped
37
+ def finish: (?drawing_rid: untyped, ?picture_rid: untyped, ?sheet_protection: untyped, ?protected_ranges: untyped, ?auto_filter: untyped, ?filter_columns: untyped, ?sort_state: untyped, ?merge_cells: untyped, ?conditional_formats: untyped, ?data_validations: untyped, ?hyperlinks: untyped, ?print_options: untyped, ?page_margins: untyped, ?page_setup: untyped, ?header_footer: untyped, ?row_breaks: untyped, ?col_breaks: untyped, ?column_breaks: untyped, ?cell_watches: untyped, ?ignored_errors: untyped, ?tables: untyped, ?table_start_rid: untyped, ?legacy_drawing_rid: untyped, ?sparkline_groups: untyped, ?phonetic_pr: untyped, ?sheet_calc_pr: untyped) -> untyped
40
38
 
41
39
  private
42
40
 
@@ -46,6 +44,10 @@ module Xlsxrb
46
44
 
47
45
  def build_tab_color_attrs: (untyped props) -> untyped
48
46
 
47
+ # Writes a hex tab color as given (without "#") and resolves a color name such as :red to
48
+ # aRGB hex, as for cell styles.
49
+ def tab_color_rgb: (untyped color) -> untyped
50
+
49
51
  def write_sheet_views: (?freeze_pane: untyped, ?split_pane: untyped, ?selection: untyped, ?sheet_view: untyped) -> untyped
50
52
 
51
53
  def write_sheet_format_pr: (untyped fmt) -> untyped
@@ -11,6 +11,13 @@ module Xlsxrb
11
11
  # : (untyped pivot_table, untyped _cache_id) -> untyped
12
12
  def generate_pivot_cache_definition_xml: (untyped pivot_table, untyped _cache_id) -> untyped
13
13
 
14
+ # Attributes that describe the value types of a cache field's shared items.
15
+ # : (Array[untyped] values) -> String
16
+ def shared_items_attrs: (untyped values) -> untyped
17
+
18
+ # : (untyped value) -> String
19
+ def shared_item_xml: (untyped value) -> untyped
20
+
14
21
  # : (untyped pivot_table) -> untyped
15
22
  def generate_pivot_cache_records_xml: (untyped pivot_table) -> untyped
16
23
 
@@ -3,6 +3,8 @@
3
3
  module Xlsxrb
4
4
  module Ooxml
5
5
  # Writes spreadsheet data into an XLSX file.
6
+ #
7
+ # @api private
6
8
  class Writer
7
9
  include DrawingXml
8
10
 
@@ -220,8 +222,6 @@ module Xlsxrb
220
222
  # : (?String | Hash[Symbol, untyped]? name, ?Float | Integer | nil size, **untyped opts) -> void
221
223
  def default_font: (?String | Hash[Symbol, untyped]? name, ?Float | Integer | nil size, **untyped opts) -> void
222
224
 
223
- alias set_default_font default_font
224
-
225
225
  # Sets the indexed colors palette (array of ARGB hex strings, e.g. ["FF000000", "FFFFFFFF"]).
226
226
  # rubocop:disable Naming/AccessorMethodName
227
227
  # : (untyped colors) -> untyped
@@ -309,9 +309,9 @@ module Xlsxrb
309
309
  # : (?sheet: untyped?) -> untyped
310
310
  def sheet_view: (?sheet: untyped) -> untyped
311
311
 
312
- # Sets a freeze pane. row: rows to freeze from top, col: columns to freeze from left.
313
- # : (?row: ::Integer, ?col: ::Integer, ?sheet: untyped?) -> untyped
314
- def set_freeze_pane: (?row: untyped, ?col: untyped, ?sheet: untyped) -> untyped
312
+ # Sets a freeze pane. row: rows to freeze from top, column: columns to freeze from left.
313
+ # : (?row: ::Integer, ?col: ::Integer?, ?column: ::Integer?, ?sheet: untyped?) -> untyped
314
+ def set_freeze_pane: (?row: untyped, ?col: untyped, ?column: untyped, ?sheet: untyped) -> untyped
315
315
 
316
316
  # Sets a split pane (non-frozen). x_split/y_split are in 1/20th of a point (twips).
317
317
  # top_left_cell: the cell at top-left of the bottom-right pane.
@@ -604,8 +604,8 @@ module Xlsxrb
604
604
  def shapes: (?sheet: untyped) -> untyped
605
605
 
606
606
  # Adds a comment on a cell.
607
- # : (untyped cell_address, untyped text, ?author: ::String, ?sheet: untyped?, ?guid: untyped?, ?shape_id: untyped?) -> untyped
608
- def add_comment: (untyped cell_address, untyped text, ?author: untyped, ?sheet: untyped, ?guid: untyped, ?shape_id: untyped) -> untyped
607
+ # : (untyped cell_address, untyped text, ?author: ::String, ?sheet: untyped?, ?guid: untyped?, ?shape_id: untyped?, ?visible: bool, ?anchor: Array[Integer]?) -> untyped
608
+ def add_comment: (untyped cell_address, untyped text, ?author: untyped, ?sheet: untyped, ?guid: untyped, ?shape_id: untyped, ?visible: untyped, ?anchor: untyped) -> untyped
609
609
 
610
610
  # Returns comment definitions for the first (or given) sheet.
611
611
  # : (?sheet: untyped?) -> untyped
@@ -632,14 +632,23 @@ module Xlsxrb
632
632
  alias person_list persons
633
633
 
634
634
  # Adds a pivot table to the given sheet.
635
- # source_ref: data source range (e.g. "Sheet1!A1:C4").
636
- # row_fields: array of 0-based field indices for row axis.
637
- # data_fields: array of { fld:, name:, subtotal: } hashes.
638
- # col_fields: array of 0-based field indices for column axis.
635
+ # source_ref: data source range (e.g. "Sheet1!A1:C4"), or nil with source_name: for a table source.
636
+ # row_fields: array of 0-based field indices, or field names listed in field_names, for row axis.
637
+ # data_fields: array of { fld:, name:, subtotal: } hashes ({ field: } takes a field name or index
638
+ # in place of fld:), or field names.
639
+ # col_fields: array of 0-based field indices, or field names, for column axis.
639
640
  # field_names: array of field name strings (for cache definition).
640
641
  # items: hash mapping field index to array of item values.
641
- # : (untyped source_ref, row_fields: untyped, data_fields: untyped, ?col_fields: untyped, ?dest_ref: ::String, ?name: untyped?, ?field_names: untyped?, ?items: untyped?, ?sheet: untyped?, **untyped opts) -> untyped
642
- def add_pivot_table: (untyped source_ref, row_fields: untyped, data_fields: untyped, ?col_fields: untyped, ?dest_ref: untyped, ?name: untyped, ?field_names: untyped, ?items: untyped, ?sheet: untyped, **untyped opts) -> untyped
642
+ # : (untyped source_ref, row_fields: untyped, data_fields: untyped, ?col_fields: untyped, ?column_fields: untyped, ?dest_ref: untyped, ?destination: untyped, ?name: untyped?, ?field_names: untyped?, ?items: untyped?, ?sheet: untyped?, **untyped opts) -> untyped
643
+ def add_pivot_table: (untyped source_ref, row_fields: untyped, data_fields: untyped, ?col_fields: untyped, ?column_fields: untyped, ?dest_ref: untyped, ?destination: untyped, ?name: untyped, ?field_names: untyped, ?items: untyped, ?sheet: untyped, **untyped opts) -> untyped
644
+
645
+ # Resolves a pivot table field given as a 0-based index or as a name in field_names.
646
+ # : (untyped field, untyped field_names) -> Integer
647
+ def resolve_pivot_field: (untyped field, untyped field_names) -> untyped
648
+
649
+ # Normalizes a pivot table data field to a Hash with an Integer fld.
650
+ # : (untyped data_field, untyped field_names) -> Hash[Symbol, untyped]
651
+ def resolve_pivot_data_field: (untyped data_field, untyped field_names) -> untyped
643
652
 
644
653
  # Returns pivot table definitions for the first (or given) sheet.
645
654
  # : (?sheet: untyped?) -> untyped
@@ -8,6 +8,76 @@ module Xlsxrb
8
8
  # Parses XML string using SAX2, calling the given listener.
9
9
  def self.parse: (untyped xml_string, untyped listener) -> untyped
10
10
 
11
+ # Returns a SAX2 parser whose listeners receive attribute values with XML entities
12
+ # decoded. REXML's SAX2 parser decodes text but passes attribute values as written, so
13
+ # formatCode=""$"0" would otherwise arrive with the " references.
14
+ # : (String xml_string) -> REXML::Parsers::SAX2Parser
15
+ def self.sax2_parser: (String xml_string) -> REXML::Parsers::SAX2Parser
16
+
17
+ # SAX2 parser that wraps each listener in an AttributeDecoder.
18
+ class DecodingSAX2Parser < REXML::Parsers::SAX2Parser
19
+ # : (*untyped args) ?{ (*untyped) -> untyped } -> untyped
20
+ def listen: (*untyped args) ?{ (*untyped) -> untyped } -> untyped
21
+ end
22
+
23
+ # Forwards SAX2 events to a listener, decoding entity references in attribute values.
24
+ class AttributeDecoder
25
+ # : (untyped listener) -> void
26
+ def initialize: (untyped listener) -> void
27
+
28
+ # Plain methods rather than define_method blocks, which Ractors cannot share.
29
+ # : (*untyped args) -> untyped
30
+ def start_document: (*untyped args) -> untyped
31
+
32
+ # : (*untyped args) -> untyped
33
+ def end_document: (*untyped args) -> untyped
34
+
35
+ # : (*untyped args) -> untyped
36
+ def start_prefix_mapping: (*untyped args) -> untyped
37
+
38
+ # : (*untyped args) -> untyped
39
+ def end_prefix_mapping: (*untyped args) -> untyped
40
+
41
+ # : (*untyped args) -> untyped
42
+ def end_element: (*untyped args) -> untyped
43
+
44
+ # : (*untyped args) -> untyped
45
+ def characters: (*untyped args) -> untyped
46
+
47
+ # : (*untyped args) -> untyped
48
+ def processing_instruction: (*untyped args) -> untyped
49
+
50
+ # : (*untyped args) -> untyped
51
+ def doctype: (*untyped args) -> untyped
52
+
53
+ # : (*untyped args) -> untyped
54
+ def attlistdecl: (*untyped args) -> untyped
55
+
56
+ # : (*untyped args) -> untyped
57
+ def elementdecl: (*untyped args) -> untyped
58
+
59
+ # : (*untyped args) -> untyped
60
+ def entitydecl: (*untyped args) -> untyped
61
+
62
+ # : (*untyped args) -> untyped
63
+ def notationdecl: (*untyped args) -> untyped
64
+
65
+ # : (*untyped args) -> untyped
66
+ def cdata: (*untyped args) -> untyped
67
+
68
+ # : (*untyped args) -> untyped
69
+ def xmldecl: (*untyped args) -> untyped
70
+
71
+ # : (*untyped args) -> untyped
72
+ def comment: (*untyped args) -> untyped
73
+
74
+ # : (*untyped args) -> untyped
75
+ def progress: (*untyped args) -> untyped
76
+
77
+ # : (String? uri, String local_name, String qname, Hash[String, String] attributes) -> untyped
78
+ def start_element: (String? uri, String local_name, String qname, Hash[String, String] attributes) -> untyped
79
+ end
80
+
11
81
  # Base listener with unmapped-data collection support.
12
82
  class BaseListener
13
83
  include REXML::SAX2Listener
@@ -3,6 +3,8 @@
3
3
  module Xlsxrb
4
4
  module Ooxml
5
5
  # Generates a simple ZIP file using only the standard library.
6
+ #
7
+ # @api private
6
8
  class ZipGenerator
7
9
  def initialize: (untyped filepath) -> untyped
8
10
 
@@ -47,8 +47,10 @@ module Xlsxrb
47
47
  # : (?Integer? length) -> String?
48
48
  def read: (?Integer? length) -> String?
49
49
 
50
- # : (?Integer chunk_size) ?{ (String) -> void } -> (void | Enumerator[String, void])
51
- def each_chunk: (?untyped chunk_size) ?{ (?) -> untyped } -> untyped
50
+ # : (?Integer chunk_size) { (String) -> void } -> void
51
+ # : (?Integer chunk_size) -> Enumerator[String, void]
52
+ def each_chunk: (?Integer chunk_size) { (String) -> void } -> void
53
+ | (?Integer chunk_size) -> Enumerator[String, void]
52
54
 
53
55
  # : () -> void
54
56
  def close: () -> void
@@ -61,6 +63,9 @@ module Xlsxrb
61
63
 
62
64
  private
63
65
 
66
+ # Drops the consumed prefix of @buffer.
67
+ def compact_buffer: () -> untyped
68
+
64
69
  def fetch_chunk: (untyped chunk_size) -> untyped
65
70
 
66
71
  def check_bom_encoding!: () -> untyped
@@ -70,8 +75,8 @@ module Xlsxrb
70
75
  # : (untyped source, ?max_uncompressed_size: Integer) ?{ (ZipReader) -> untyped } -> (ZipReader | untyped)
71
76
  def self.open: (untyped source, ?max_uncompressed_size: Integer) ?{ (ZipReader) -> untyped } -> (ZipReader | untyped)
72
77
 
73
- # : (untyped io, ?max_uncompressed_size: Integer, ?should_close_io: bool) -> void
74
- def initialize: (untyped io, ?max_uncompressed_size: Integer, ?should_close_io: bool) -> void
78
+ # : (untyped io, ?max_uncompressed_size: Integer, ?should_close_io: bool, ?filepath: String?) -> void
79
+ def initialize: (untyped io, ?max_uncompressed_size: Integer, ?should_close_io: bool, ?filepath: String?) -> void
75
80
 
76
81
  # Returns a Hash { entry_name => raw_bytes } for all entries.
77
82
  # : () -> Hash[String, String?]
@@ -82,16 +87,20 @@ module Xlsxrb
82
87
  def read_entry: (String name) -> String?
83
88
 
84
89
  # Yields (entry_name, data_string) for each file in the archive.
85
- # : () ?{ (String, String?) -> void } -> (void | Enumerator[[String, String?], void])
86
- def each_entry: () ?{ (?) -> untyped } -> untyped
90
+ # : () { (String, String?) -> void } -> void
91
+ # : () -> Enumerator[[String, String?], void]
92
+ def each_entry: () { (String, String?) -> void } -> void
93
+ | () -> Enumerator[[ String, String? ], void]
87
94
 
88
95
  # Opens an EntryStreamIO for an entry by name.
89
96
  # : (String entry_name, ?encoding: (Encoding | String | false | nil)) -> EntryStreamIO
90
97
  def open_entry_io: (String entry_name, ?encoding: Encoding | String | false | nil) -> EntryStreamIO
91
98
 
92
99
  # Yields inflated binary chunks directly from the compressed stream.
93
- # : (String entry_name, ?chunk_size: Integer, ?encoding: (Encoding | String | false | nil)) ?{ (String) -> void } -> (void | Enumerator[String, void])
94
- def each_entry_chunk: (untyped entry_name, ?chunk_size: untyped, ?encoding: untyped) ?{ (?) -> untyped } -> untyped
100
+ # : (String entry_name, ?chunk_size: Integer, ?encoding: (Encoding | String | false | nil)) { (String) -> void } -> void
101
+ # : (String entry_name, ?chunk_size: Integer, ?encoding: (Encoding | String | false | nil)) -> Enumerator[String, void]
102
+ def each_entry_chunk: (String entry_name, ?chunk_size: Integer, ?encoding: Encoding | String | false | nil) { (String) -> void } -> void
103
+ | (String entry_name, ?chunk_size: Integer, ?encoding: Encoding | String | false | nil) -> Enumerator[String, void]
95
104
 
96
105
  # Returns true if the archive contains the specified entry.
97
106
  # : (String name) -> bool
@@ -125,7 +134,7 @@ module Xlsxrb
125
134
 
126
135
  def parse_catalog_from_local_headers: (untyped io) -> untyped
127
136
 
128
- def find_data_descriptor_stream: (untyped io, untyped method) -> untyped
137
+ def find_data_descriptor_stream: (untyped io, untyped method, ?zip64: untyped) -> untyped
129
138
 
130
139
  def decompress: (untyped raw, untyped method) -> untyped
131
140
 
@@ -139,6 +148,12 @@ module Xlsxrb
139
148
 
140
149
  def normalize_text_encoding: (untyped data) -> untyped
141
150
 
151
+ # Reads the entry count and central directory offset from the ZIP64 end of central
152
+ # directory record, located through the locator just before the end of central directory.
153
+ # Returns the given values unchanged when the archive has no ZIP64 record.
154
+ # : (untyped io, Integer eocd_pos, Integer total_entries, Integer cd_offset) -> [Integer, Integer]
155
+ def read_zip64_end_of_central_directory: (untyped io, Integer eocd_pos, Integer total_entries, Integer cd_offset) -> [ Integer, Integer ]
156
+
142
157
  # : (String extra_data, Integer usize, Integer csize, Integer offset) -> [Integer, Integer, Integer]
143
158
  def parse_zip64_extra: (String extra_data, Integer usize, Integer csize, Integer offset) -> [ Integer, Integer, Integer ]
144
159
  end
@@ -4,7 +4,21 @@ module Xlsxrb
4
4
  module Ooxml
5
5
  # Writes ZIP archives using only stdlib (zlib).
6
6
  # Supports streaming: entries are written sequentially, central directory at close.
7
+ #
8
+ # Sizes, offsets, and entry counts that do not fit the 32-bit (16-bit for counts)
9
+ # fields switch to ZIP64 records for that value only, so archives below those
10
+ # limits are written exactly as plain ZIP.
7
11
  class ZipWriter
12
+ MAX_UINT32: ::Integer
13
+
14
+ MAX_UINT16: ::Integer
15
+
16
+ VERSION_DEFAULT: ::Integer
17
+
18
+ VERSION_ZIP64: ::Integer
19
+
20
+ DATA_DESCRIPTOR_FLAG: ::Integer
21
+
8
22
  def self.open: (untyped target, ?compression_level: untyped) ?{ (?) -> untyped } -> untyped
9
23
 
10
24
  # @return [Integer] Deflate compression level (0..9).
@@ -12,6 +26,7 @@ module Xlsxrb
12
26
 
13
27
  # @param io [IO, StringIO] Destination IO stream.
14
28
  # @param compression_level [Integer, nil] ZIP deflate compression level (0..9, or Zlib::DEFAULT_COMPRESSION).
29
+ # nil selects {Xlsxrb::DEFAULT_COMPRESSION_LEVEL}.
15
30
  # : (untyped io, ?compression_level: Integer | nil) -> void
16
31
  def initialize: (untyped io, ?compression_level: Integer | nil) -> void
17
32
 
@@ -39,13 +54,23 @@ module Xlsxrb
39
54
 
40
55
  def determine_seekable: () -> untyped
41
56
 
57
+ # : (Integer value) -> bool
58
+ def zip64?: (Integer value) -> bool
59
+
60
+ # : () { () -> void } -> void
61
+ def patch_local_header: () { () -> void } -> void
62
+
63
+ # Data descriptor: signature + crc32 + compressed size + uncompressed size.
64
+ # ZIP64 entries store both sizes as 8-byte values (APPNOTE 4.3.9.1).
65
+ def write_data_descriptor: (untyped crc, untyped compressed_size, untyped uncompressed_size, zip64: untyped) -> untyped
66
+
42
67
  def write_bytes: (untyped data) -> untyped
43
68
 
44
69
  def write_raw_entry: (untyped path, untyped content_bytes) -> untyped
45
70
 
46
71
  def deflate: (untyped content) -> untyped
47
72
 
48
- def write_local_header: (untyped path, untyped crc, untyped compressed_size, untyped uncompressed_size, ?gp_flag: untyped, ?count_bytes: untyped, ?method: untyped) -> untyped
73
+ def write_local_header: (untyped path, untyped crc, untyped compressed_size, untyped uncompressed_size, ?gp_flag: untyped, ?count_bytes: untyped, ?method: untyped, ?version: untyped) -> untyped
49
74
 
50
75
  def write_central_directory: () -> untyped
51
76
 
@@ -15,22 +15,18 @@ module Xlsxrb
15
15
  #
16
16
  # @api public
17
17
  class StreamRow
18
+ # : Integer
18
19
  attr_reader index: untyped
19
20
 
21
+ # : (Float | Integer)?
20
22
  attr_reader height: untyped
21
23
 
22
- attr_reader hidden: untyped
23
-
24
- attr_reader custom_height: untyped
25
-
26
- attr_reader collapsed: untyped
27
-
24
+ # : Integer?
28
25
  attr_reader outline_level: untyped
29
26
 
27
+ # : Integer?
30
28
  attr_reader style_index: untyped
31
29
 
32
- attr_reader pad_empty_cells: untyped
33
-
34
30
  # @param index [Integer] 0-based row index.
35
31
  # @param xml_bytes [String] Raw ASCII-8BIT XML bytes.
36
32
  # @param from [Integer] Byte offset where cells start.
@@ -49,6 +45,7 @@ module Xlsxrb
49
45
  # : (index: Integer, xml_bytes: String, from: Integer, to: Integer, shared_strings: Array[String], ?prefix: String, ?height: Float | Integer | nil, ?hidden: bool, ?custom_height: bool, ?collapsed: bool, ?outline_level: Integer | nil, ?style_index: Integer | nil, ?styles: (Elements::Styles | Hash[untyped, untyped])?, ?date1904: bool, ?pad_empty_cells: bool) -> void
50
46
  def initialize: (index: Integer, xml_bytes: String, from: Integer, to: Integer, shared_strings: Array[String], ?prefix: String, ?height: Float | Integer | nil, ?hidden: bool, ?custom_height: bool, ?collapsed: bool, ?outline_level: Integer | nil, ?style_index: Integer | nil, ?styles: (Elements::Styles | Hash[untyped, untyped])?, ?date1904: bool, ?pad_empty_cells: bool) -> void
51
47
 
48
+ # @api private
52
49
  # rubocop:disable Style/OptionalBooleanParameter
53
50
  def self.fast_create: (untyped index, untyped xml_bytes, untyped from, untyped to, untyped shared_strings, ?untyped prefix, ?untyped height, ?untyped hidden, ?untyped custom_height, ?untyped outline_level, ?untyped style_index, ?untyped styles, ?untyped date1904, ?untyped collapsed, ?untyped pad_empty_cells) -> untyped
54
51
 
@@ -73,6 +70,21 @@ module Xlsxrb
73
70
  # : () -> bool
74
71
  def custom_height?: () -> bool
75
72
 
73
+ # Deconstructs row values for positional pattern matching.
74
+ #
75
+ # @return [Array<Object>]
76
+ # @api public
77
+ # : () -> Array[untyped]
78
+ def deconstruct: () -> Array[untyped]
79
+
80
+ # Deconstructs row attributes for pattern matching.
81
+ #
82
+ # @param _keys [Array<Symbol>, nil]
83
+ # @return [Hash{Symbol => Object}]
84
+ # @api public
85
+ # : (Array[Symbol]? _keys) -> Hash[Symbol, untyped]
86
+ def deconstruct_keys: (Array[Symbol]? _keys) -> Hash[Symbol, untyped]
87
+
76
88
  # Returns a frozen Hash of row attributes.
77
89
  #
78
90
  # @return [Hash{Symbol => Object}]
@@ -123,36 +135,23 @@ module Xlsxrb
123
135
  # : () -> Array[Elements::Cell]
124
136
  def cells: () -> Array[Elements::Cell]
125
137
 
126
- # Access a cell by 0-based column index, or access row attributes via Symbol.
138
+ # Access a cell by 0-based column index, column letter/Symbol, or column range.
127
139
  #
128
- # @param col_index [Integer, Symbol] Column index or attribute symbol.
129
- # @return [Elements::Cell, Object, nil]
140
+ # @param col_index_or_range [Integer, String, Symbol, Range<Integer>] Column index, column letter/Symbol, or column index range.
141
+ # @return [Elements::Cell, Array<Elements::Cell>, nil]
130
142
  # @api public
131
- # : (Integer | Symbol col_index) -> untyped
132
- def []: (Integer | Symbol col_index) -> untyped
143
+ # : (Integer | String | Symbol col_index_or_range) -> Elements::Cell?
144
+ # : (Range[Integer] col_index_or_range) -> Array[Elements::Cell]
145
+ def []: (Integer | String | Symbol col_index_or_range) -> Elements::Cell?
146
+ | (Range[Integer] col_index_or_range) -> Array[Elements::Cell]
133
147
 
134
- # Access a cell by 0-based column index.
148
+ # Access a cell by 0-based column index or column letter/Symbol.
135
149
  #
136
- # @param col_index [Integer] 0-based column index.
150
+ # @param col_index [Integer, String, Symbol] 0-based column index or column letter/Symbol.
137
151
  # @return [Elements::Cell, nil]
138
152
  # @api public
139
- # : (Integer col_index) -> Elements::Cell?
140
- def cell_at: (Integer col_index) -> Elements::Cell?
141
-
142
- # Convert row cells to a coordinate-keyed Hash (e.g. {"A1" => "value", "B1" => 123}).
143
- #
144
- # @param type_cast [Boolean] Whether to coerce date/time serial numbers into Date/Time instances.
145
- # @return [Hash{String => Object}]
146
- # @api public
147
- # : (?type_cast: bool) -> Hash[String, untyped]
148
- def to_h: (?type_cast: bool) -> Hash[String, untyped]
149
-
150
- # Convert row cells to an Array of raw values (sparse columns get nil).
151
- #
152
- # @return [Array<Object>]
153
- # @api public
154
- # : () -> Array[untyped]
155
- def to_a: () -> Array[untyped]
153
+ # : (Integer | String | Symbol col_index) -> Elements::Cell?
154
+ def cell_at: (Integer | String | Symbol col_index) -> Elements::Cell?
156
155
 
157
156
  # Returns cell values as an Array (sparse columns get nil).
158
157
  #
@@ -181,7 +180,7 @@ module Xlsxrb
181
180
  # @return [Array<String, nil>]
182
181
  # @api public
183
182
  # : () -> Array[String?]
184
- def formulas: () -> Array[String?]
183
+ def formula_expressions: () -> Array[String?]
185
184
 
186
185
  # Returns whether the row is valid according to OOXML specifications.
187
186
  #