Class: Xlsxrb::StreamSheet
- Inherits:
-
Object
- Object
- Xlsxrb::StreamSheet
- Defined in:
- lib/xlsxrb/stream_sheet.rb,
sig/generated/xlsxrb/stream_sheet.rbs
Overview
Represents a worksheet being streamed sequentially from an XLSX file. Provides O(1) constant-memory streaming over rows and cells.
Call #load (or #to_worksheet) to convert this streaming sheet into an
in-memory Elements::Worksheet supporting coordinate random access (sheet["A1"]).
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
: String.
Instance Method Summary collapse
-
#each {|arg0| ... } ⇒ Object
Default Enumerable iteration delegates to #each_row.
-
#each_cell {|arg0| ... } ⇒ Object
Iterates over all cells across all rows continuously with O(1) memory.
-
#each_row {|arg0| ... } ⇒ Object
Iterates over rows in this streaming worksheet with O(1) memory.
-
#initialize(name, sheet_xml, shared_strings, styles = nil) ⇒ StreamSheet
constructor
Initializes a streaming worksheet context.
-
#load ⇒ Elements::Worksheet
(also: #to_worksheet)
Loads this sheet completely into an in-memory Elements::Worksheet, enabling coordinate random access (
sheet["A1"]), row lookups (row_at), and immutable cell updates (update_cell).
Constructor Details
#initialize(name, sheet_xml, shared_strings, styles = nil) ⇒ StreamSheet
Initializes a streaming worksheet context.
: (String name, String sheet_xml, Array shared_strings, ?Hash[untyped, untyped]? styles) -> void
43 44 45 46 47 48 |
# File 'lib/xlsxrb/stream_sheet.rb', line 43 def initialize(name, sheet_xml, shared_strings, styles = nil) @name = name @sheet_xml = sheet_xml @shared_strings = shared_strings @styles = styles end |
Instance Attribute Details
#name ⇒ String (readonly)
: String
34 35 36 |
# File 'lib/xlsxrb/stream_sheet.rb', line 34 def name @name end |
Instance Method Details
#each {|row| ... } ⇒ void #each ⇒ Enumerator<StreamRow | Elements::Row, void> #each ⇒ void #each ⇒ Enumerator[StreamRow | Elements::Row, void]
Default Enumerable iteration delegates to #each_row.
: () { (StreamRow | Elements::Row) -> void } -> void : () -> Enumerator[StreamRow | Elements::Row, void]
103 104 105 |
# File 'lib/xlsxrb/stream_sheet.rb', line 103 def each(&) each_row(&) end |
#each_cell {|cell| ... } ⇒ void #each_cell ⇒ Enumerator<Elements::Cell, void> #each_cell ⇒ void #each_cell ⇒ Enumerator[Elements::Cell, void]
Iterates over all cells across all rows continuously with O(1) memory.
: () { (Elements::Cell) -> void } -> void : () -> Enumerator[Elements::Cell, void]
82 83 84 85 86 87 88 |
# File 'lib/xlsxrb/stream_sheet.rb', line 82 def each_cell(&) return enum_for(:each_cell) unless block_given? each_row do |row| row.each_cell(&) end end |
#each_row {|row| ... } ⇒ void #each_row ⇒ Enumerator<StreamRow | Elements::Row, void> #each_row ⇒ void #each_row ⇒ Enumerator[StreamRow | Elements::Row, void]
Iterates over rows in this streaming worksheet with O(1) memory.
: () { (StreamRow | Elements::Row) -> void } -> void : () -> Enumerator[StreamRow | Elements::Row, void]
63 64 65 66 67 |
# File 'lib/xlsxrb/stream_sheet.rb', line 63 def each_row(&) return enum_for(:each_row) unless block_given? Ooxml::WorksheetParser.each_row(@sheet_xml, shared_strings: @shared_strings, &) end |
#load ⇒ Elements::Worksheet Also known as: to_worksheet
Loads this sheet completely into an in-memory Elements::Worksheet,
enabling coordinate random access (sheet["A1"]), row lookups (row_at),
and immutable cell updates (update_cell).
: () -> Elements::Worksheet
114 115 116 |
# File 'lib/xlsxrb/stream_sheet.rb', line 114 def load Xlsxrb.send(:build_worksheet, @name, @sheet_xml, @shared_strings, @styles) end |