xlsxrb 0.1.18 → 0.2.1

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 (77) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +200 -0
  3. data/README.md +35 -12
  4. data/lib/ruby_lsp/xlsxrb/completion_listener.rb +410 -80
  5. data/lib/xlsxrb/chart_builder.rb +251 -386
  6. data/lib/xlsxrb/dsl_helpers.rb +169 -68
  7. data/lib/xlsxrb/elements/cell.rb +37 -157
  8. data/lib/xlsxrb/elements/column.rb +11 -19
  9. data/lib/xlsxrb/elements/coordinate_access.rb +15 -86
  10. data/lib/xlsxrb/elements/image.rb +5 -72
  11. data/lib/xlsxrb/elements/metadata.rb +463 -817
  12. data/lib/xlsxrb/elements/row.rb +27 -145
  13. data/lib/xlsxrb/elements/styles.rb +30 -88
  14. data/lib/xlsxrb/elements/types.rb +6 -99
  15. data/lib/xlsxrb/elements/workbook.rb +19 -126
  16. data/lib/xlsxrb/elements/worksheet.rb +45 -316
  17. data/lib/xlsxrb/ooxml/reader/listeners/core_listeners.rb +4 -1
  18. data/lib/xlsxrb/ooxml/reader/listeners/drawing_listeners.rb +7 -7
  19. data/lib/xlsxrb/ooxml/reader/listeners/feature_listeners.rb +32 -17
  20. data/lib/xlsxrb/ooxml/reader.rb +49 -51
  21. data/lib/xlsxrb/ooxml/styles_parser.rb +26 -2
  22. data/lib/xlsxrb/ooxml/utils.rb +15 -2
  23. data/lib/xlsxrb/ooxml/workbook_parser.rb +0 -1
  24. data/lib/xlsxrb/ooxml/workbook_writer.rb +184 -94
  25. data/lib/xlsxrb/ooxml/worksheet_parser.rb +61 -29
  26. data/lib/xlsxrb/ooxml/worksheet_writer.rb +353 -261
  27. data/lib/xlsxrb/ooxml/writer/drawing_xml.rb +28 -11
  28. data/lib/xlsxrb/ooxml/writer/features_xml.rb +62 -16
  29. data/lib/xlsxrb/ooxml/writer/styles_xml.rb +1 -1
  30. data/lib/xlsxrb/ooxml/writer.rb +106 -42
  31. data/lib/xlsxrb/ooxml/xml_builder.rb +18 -0
  32. data/lib/xlsxrb/ooxml/xml_parser.rb +78 -5
  33. data/lib/xlsxrb/ooxml/zip_reader.rb +65 -15
  34. data/lib/xlsxrb/ooxml/zip_writer.rb +119 -30
  35. data/lib/xlsxrb/stream_row.rb +14 -118
  36. data/lib/xlsxrb/stream_sheet.rb +14 -261
  37. data/lib/xlsxrb/stream_writer.rb +807 -1537
  38. data/lib/xlsxrb/style_builder.rb +715 -593
  39. data/lib/xlsxrb/version.rb +1 -1
  40. data/lib/xlsxrb/workbook_builder.rb +403 -286
  41. data/lib/xlsxrb/worksheet_builder.rb +1297 -1458
  42. data/lib/xlsxrb.rb +281 -1079
  43. data/sig/generated/xlsxrb/chart_builder.rbs +202 -205
  44. data/sig/generated/xlsxrb/dsl_helpers.rbs +92 -16
  45. data/sig/generated/xlsxrb/elements/cell.rbs +12 -76
  46. data/sig/generated/xlsxrb/elements/column.rbs +0 -7
  47. data/sig/generated/xlsxrb/elements/coordinate_access.rbs +5 -41
  48. data/sig/generated/xlsxrb/elements/image.rbs +3 -29
  49. data/sig/generated/xlsxrb/elements/metadata.rbs +138 -151
  50. data/sig/generated/xlsxrb/elements/row.rbs +10 -53
  51. data/sig/generated/xlsxrb/elements/styles.rbs +1 -39
  52. data/sig/generated/xlsxrb/elements/workbook.rbs +14 -78
  53. data/sig/generated/xlsxrb/elements/worksheet.rbs +5 -121
  54. data/sig/generated/xlsxrb/ooxml/reader/listeners/feature_listeners.rbs +0 -4
  55. data/sig/generated/xlsxrb/ooxml/reader.rbs +0 -3
  56. data/sig/generated/xlsxrb/ooxml/styles_parser.rbs +1 -1
  57. data/sig/generated/xlsxrb/ooxml/utils.rbs +13 -3
  58. data/sig/generated/xlsxrb/ooxml/workbook_writer.rbs +17 -0
  59. data/sig/generated/xlsxrb/ooxml/worksheet_parser.rbs +16 -0
  60. data/sig/generated/xlsxrb/ooxml/worksheet_writer.rbs +58 -3
  61. data/sig/generated/xlsxrb/ooxml/writer/features_xml.rbs +10 -0
  62. data/sig/generated/xlsxrb/ooxml/writer.rbs +20 -14
  63. data/sig/generated/xlsxrb/ooxml/xml_builder.rbs +12 -0
  64. data/sig/generated/xlsxrb/ooxml/xml_parser.rbs +70 -0
  65. data/sig/generated/xlsxrb/ooxml/zip_reader.rbs +22 -7
  66. data/sig/generated/xlsxrb/ooxml/zip_writer.rbs +26 -1
  67. data/sig/generated/xlsxrb/stream_row.rbs +9 -44
  68. data/sig/generated/xlsxrb/stream_sheet.rbs +1 -158
  69. data/sig/generated/xlsxrb/stream_writer.rbs +491 -974
  70. data/sig/generated/xlsxrb/style_builder.rbs +464 -239
  71. data/sig/generated/xlsxrb/workbook_builder.rbs +124 -139
  72. data/sig/generated/xlsxrb/worksheet_builder.rbs +922 -686
  73. data/sig/generated/xlsxrb.rbs +56 -188
  74. data/sig/rexml.rbs +8 -0
  75. metadata +3 -5
  76. data/lib/xlsxrb/utils.rb +0 -251
  77. data/sig/generated/xlsxrb/utils.rbs +0 -200
@@ -13,12 +13,43 @@ 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
+ # Matches a value that claims to be a Time through is_a? without being one, such as
17
+ # ActiveSupport::TimeWithZone, which `when Time` does not match. The writers try it
18
+ # after their Time and Date branches, so other values never reach it. Such a value
19
+ # is written as the Time that to_time gives.
20
+ # @api private
21
+ module TimeLike
22
+ # : (untyped value) -> bool
23
+ def self.===: (untyped value) -> bool
24
+
25
+ # A Time with the value's year, month, day, hour, minute, second, and UTC offset,
26
+ # which keeps its wall clock.
27
+ # : (untyped value) -> Time
28
+ def self.to_time: (untyped value) -> Time
29
+ end
30
+
31
+ def initialize: (untyped io, ?date1904: untyped) -> untyped
32
+
33
+ # Makes the row writers reject text longer than a cell holds (32,767 characters),
34
+ # as the strict Excel mode of the caller asks.
35
+ # @api private
36
+ # : (bool strict) -> void
37
+ def strict_excel_mode=: (bool strict) -> void
38
+
39
+ # Sets what gives the style id for a Time-like value in a styled cell, so that a
40
+ # style without a number format can be given its date-time variant.
41
+ # @api private
42
+ # : (untyped resolver) -> void
43
+ attr_writer time_like_style_resolver: untyped
19
44
 
20
45
  def set_column_style: (untyped col_index, untyped style_id) -> untyped
21
46
 
47
+ # Drops the resolved column style ids, for a caller that changed the style id a
48
+ # name in the style map stands for.
49
+ # @api private
50
+ # : () -> void
51
+ def forget_column_style_ids: () -> void
52
+
22
53
  # Write the worksheet header. Call once before writing rows.
23
54
  # Options for pre-sheetData elements:
24
55
  # sheet_properties: Hash of sheet-level properties (:tab_color, etc.)
@@ -40,12 +71,31 @@ module Xlsxrb
40
71
 
41
72
  private
42
73
 
74
+ # Writes the cells of a row that has cell styles, row attributes, or column styles.
75
+ # It is not inlined in write_row_values because YJIT ran the same loop there about
76
+ # 1.6 times slower, after the row attribute handling.
77
+ def write_styled_cells: (untyped buf, untyped values, untyped max_len, untyped row_num_str, untyped styles, untyped is_styles_collection, untyped single_style_id, untyped row_style_id, untyped style_map, untyped sst, untyped sst_index) -> untyped
78
+
79
+ # The style id of each column style, indexed by column, resolved once instead of
80
+ # for every cell. It is resolved again when the style map is another Hash, or after
81
+ # set_column_style or forget_column_style_ids.
82
+ # : (Hash[untyped, Integer]? style_map) -> Array[Integer?]
83
+ def column_style_ids: (Hash[untyped, Integer]? style_map) -> Array[Integer?]
84
+
85
+ # Writes a cell for write_styled_cells whose value is a formula, rich text, BigDecimal,
86
+ # cell error, or another value that write_styled_cells does not write itself.
87
+ def write_complex_cell: (untyped buf, untyped col_ref, untyped row_num_str, untyped value, untyped style_id, untyped sst, untyped sst_index) -> untyped
88
+
43
89
  def resolve_style_id: (untyped style, untyped style_map) -> untyped
44
90
 
45
91
  def write_sheet_properties: (untyped props) -> untyped
46
92
 
47
93
  def build_tab_color_attrs: (untyped props) -> untyped
48
94
 
95
+ # Writes a hex tab color as given (without "#") and resolves a color name such as :red to
96
+ # aRGB hex, as for cell styles.
97
+ def tab_color_rgb: (untyped color) -> untyped
98
+
49
99
  def write_sheet_views: (?freeze_pane: untyped, ?split_pane: untyped, ?selection: untyped, ?sheet_view: untyped) -> untyped
50
100
 
51
101
  def write_sheet_format_pr: (untyped fmt) -> untyped
@@ -114,6 +164,11 @@ module Xlsxrb
114
164
  ESCAPE_MAP: untyped
115
165
 
116
166
  def escape_xml: (untyped value) -> untyped
167
+
168
+ # Escapes cell text: encodes it as ST_Xstring (XmlBuilder.encode_xstring), so that
169
+ # text that looks like _xHHHH_ and characters XML 1.0 cannot hold are read back as
170
+ # written, then escapes the XML special characters.
171
+ def escape_text: (untyped value) -> untyped
117
172
  end
118
173
  end
119
174
  end
@@ -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
 
@@ -33,6 +40,9 @@ module Xlsxrb
33
40
  def build_line_end_xml: (untyped element, untyped opts) -> untyped
34
41
 
35
42
  # : (untyped value) -> untyped
43
+ # Escapes cell text: ST_Xstring (XmlBuilder.encode_xstring), then XML.
44
+ def xml_escape_text: (untyped value) -> untyped
45
+
36
46
  def xml_escape: (untyped value) -> untyped
37
47
 
38
48
  # : (untyped rich_text) -> untyped
@@ -222,9 +222,6 @@ module Xlsxrb
222
222
  # : (?String | Hash[Symbol, untyped]? name, ?Float | Integer | nil size, **untyped opts) -> void
223
223
  def default_font: (?String | Hash[Symbol, untyped]? name, ?Float | Integer | nil size, **untyped opts) -> void
224
224
 
225
- # @deprecated Use {#default_font} instead. Will be removed in 0.2.0.
226
- alias set_default_font default_font
227
-
228
225
  # Sets the indexed colors palette (array of ARGB hex strings, e.g. ["FF000000", "FFFFFFFF"]).
229
226
  # rubocop:disable Naming/AccessorMethodName
230
227
  # : (untyped colors) -> untyped
@@ -312,9 +309,9 @@ module Xlsxrb
312
309
  # : (?sheet: untyped?) -> untyped
313
310
  def sheet_view: (?sheet: untyped) -> untyped
314
311
 
315
- # Sets a freeze pane. row: rows to freeze from top, col: columns to freeze from left.
316
- # : (?row: ::Integer, ?col: ::Integer, ?sheet: untyped?) -> untyped
317
- 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
318
315
 
319
316
  # Sets a split pane (non-frozen). x_split/y_split are in 1/20th of a point (twips).
320
317
  # top_left_cell: the cell at top-left of the bottom-right pane.
@@ -607,8 +604,8 @@ module Xlsxrb
607
604
  def shapes: (?sheet: untyped) -> untyped
608
605
 
609
606
  # Adds a comment on a cell.
610
- # : (untyped cell_address, untyped text, ?author: ::String, ?sheet: untyped?, ?guid: untyped?, ?shape_id: untyped?) -> untyped
611
- 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
612
609
 
613
610
  # Returns comment definitions for the first (or given) sheet.
614
611
  # : (?sheet: untyped?) -> untyped
@@ -635,14 +632,23 @@ module Xlsxrb
635
632
  alias person_list persons
636
633
 
637
634
  # Adds a pivot table to the given sheet.
638
- # source_ref: data source range (e.g. "Sheet1!A1:C4").
639
- # row_fields: array of 0-based field indices for row axis.
640
- # data_fields: array of { fld:, name:, subtotal: } hashes.
641
- # 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.
642
640
  # field_names: array of field name strings (for cache definition).
643
641
  # items: hash mapping field index to array of item values.
644
- # : (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
645
- 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
646
652
 
647
653
  # Returns pivot table definitions for the first (or given) sheet.
648
654
  # : (?sheet: untyped?) -> untyped
@@ -46,6 +46,18 @@ module Xlsxrb
46
46
  # : (untyped value) -> String
47
47
  def self.escape: (untyped value) -> String
48
48
 
49
+ XSTRING_ENCODE_RE: ::Regexp
50
+
51
+ # Encodes cell text as ISO/IEC 29500-1 ST_Xstring, the inverse of the _xHHHH_ part
52
+ # of unescape: an underscore that starts an _xHHHH_ sequence becomes _x005F_, and a
53
+ # character that XML 1.0 cannot hold, such as U+0001 or U+FFFE, becomes _xHHHH_.
54
+ # Excel and unescape read the original text back. The value must be UTF-8.
55
+ #
56
+ # @param value [String]
57
+ # @return [String]
58
+ # : (String value) -> String
59
+ def self.encode_xstring: (String value) -> String
60
+
49
61
  NUM_ENTITY_RE: ::Regexp
50
62
 
51
63
  XSTRING_RE: ::Regexp
@@ -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
@@ -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
@@ -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
 
@@ -9,9 +9,9 @@ module Xlsxrb
9
9
  # puts "#{cell.ref}: #{cell.value}"
10
10
  # end
11
11
  #
12
- # @example Random access or array conversion (cached on-demand)
12
+ # @example Random access or the row's values (cached on-demand)
13
13
  # cell = row[0]
14
- # values = row.to_a
14
+ # values = row.values
15
15
  #
16
16
  # @api public
17
17
  class StreamRow
@@ -27,22 +27,6 @@ module Xlsxrb
27
27
  # : Integer?
28
28
  attr_reader style_index: untyped
29
29
 
30
- # @deprecated Use {#hidden?} instead. Will be removed in 0.2.0.
31
- # : () -> bool
32
- def hidden: () -> bool
33
-
34
- # @deprecated Use {#collapsed?} instead. Will be removed in 0.2.0.
35
- # : () -> bool
36
- def collapsed: () -> bool
37
-
38
- # @deprecated Use {#custom_height?} instead. Will be removed in 0.2.0.
39
- # : () -> bool
40
- def custom_height: () -> bool
41
-
42
- # @deprecated Use {#pad_empty_cells?} instead. Will be removed in 0.2.0.
43
- # : () -> bool
44
- def pad_empty_cells: () -> bool
45
-
46
30
  # @param index [Integer] 0-based row index.
47
31
  # @param xml_bytes [String] Raw ASCII-8BIT XML bytes.
48
32
  # @param from [Integer] Byte offset where cells start.
@@ -151,13 +135,15 @@ module Xlsxrb
151
135
  # : () -> Array[Elements::Cell]
152
136
  def cells: () -> Array[Elements::Cell]
153
137
 
154
- # Access a cell by 0-based column index, column letter, or access row attributes via Symbol.
138
+ # Access a cell by 0-based column index, column letter/Symbol, or column range.
155
139
  #
156
- # @param col_index [Integer, String, Symbol] Column index, column letter, or attribute symbol.
157
- # @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]
158
142
  # @api public
159
- # : (Integer | String | Symbol col_index) -> untyped
160
- def []: (Integer | String | 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]
161
147
 
162
148
  # Access a cell by 0-based column index or column letter/Symbol.
163
149
  #
@@ -167,23 +153,6 @@ module Xlsxrb
167
153
  # : (Integer | String | Symbol col_index) -> Elements::Cell?
168
154
  def cell_at: (Integer | String | Symbol col_index) -> Elements::Cell?
169
155
 
170
- # Convert row cells to a coordinate-keyed Hash (e.g. {"A1" => "value", "B1" => 123}).
171
- #
172
- # @deprecated Use {#values} or {#cells} instead. Will be removed in 0.2.0.
173
- # @param type_cast [Boolean] Whether to coerce date/time serial numbers into Date/Time instances.
174
- # @return [Hash{String => Object}]
175
- # @api public
176
- # : (?type_cast: bool) -> Hash[String, untyped]
177
- def to_h: (?type_cast: bool) -> Hash[String, untyped]
178
-
179
- # Convert row cells to an Array of raw values (sparse columns get nil).
180
- #
181
- # @deprecated Use {#values} to get an Array of cell values, or {#cells} for Cell objects. In 0.2.0, {#to_a} will conform to Enumerable#to_a and return Array<Cell>.
182
- # @return [Array<Object>]
183
- # @api public
184
- # : () -> Array[untyped]
185
- def to_a: () -> Array[untyped]
186
-
187
156
  # Returns cell values as an Array (sparse columns get nil).
188
157
  #
189
158
  # @param type_cast [Boolean] Whether to coerce date/time serial numbers into Date/Time instances.
@@ -213,10 +182,6 @@ module Xlsxrb
213
182
  # : () -> Array[String?]
214
183
  def formula_expressions: () -> Array[String?]
215
184
 
216
- # @deprecated Use {#formula_expressions} instead. Will be removed in 0.2.0.
217
- # : () -> Array[String?]
218
- def formulas: () -> Array[String?]
219
-
220
185
  # Returns whether the row is valid according to OOXML specifications.
221
186
  #
222
187
  # @return [Boolean]