Class: Xlsxrb::StreamSheet
- Inherits:
-
Object
- Object
- Xlsxrb::StreamSheet
- Defined in:
- lib/xlsxrb.rb,
sig/generated/xlsxrb.rbs
Overview
Represents a sheet 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).
Instance Attribute Summary collapse
- #name ⇒ Object readonly
Instance Method Summary collapse
-
#each {|row| ... } ⇒ Enumerator, void
Default Enumerable iteration iterates rows in the streaming sheet.
-
#each_cell {|cell| ... } ⇒ Enumerator, void
Iterate over all cells across rows continuously (O(1) memory).
-
#each_row {|row| ... } ⇒ Enumerator, void
Iterate over rows in this streaming sheet (O(1) memory).
-
#initialize(name, sheet_xml, shared_strings, styles = nil) ⇒ StreamSheet
constructor
: (String name, String sheet_xml, Array shared_strings, ?Hash[untyped, untyped]? styles) -> void.
-
#load ⇒ Elements::Worksheet
(also: #to_worksheet)
Loads this sheet completely into an in-memory Elements::Worksheet, enabling coordinate random access (sheet), row lookups (row_at), and immutable cell updates (update_cell).
Constructor Details
#initialize(name, sheet_xml, shared_strings, styles = nil) ⇒ StreamSheet
: (String name, String sheet_xml, Array shared_strings, ?Hash[untyped, untyped]? styles) -> void
616 617 618 619 620 621 |
# File 'lib/xlsxrb.rb', line 616 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 ⇒ Object (readonly)
609 610 611 |
# File 'lib/xlsxrb.rb', line 609 def name @name end |
Instance Method Details
#each {|row| ... } ⇒ Enumerator, void
Default Enumerable iteration iterates rows in the streaming sheet.
: () { (StreamRow | Elements::Row) -> void } -> void : | () -> Enumerator[StreamRow | Elements::Row, void]
667 668 669 |
# File 'lib/xlsxrb.rb', line 667 def each(&) each_row(&) end |
#each_cell {|cell| ... } ⇒ Enumerator, void
Iterate over all cells across rows continuously (O(1) memory).
: () { (Elements::Cell) -> void } -> void : | () -> Enumerator[Elements::Cell, void]
651 652 653 654 655 656 657 |
# File 'lib/xlsxrb.rb', line 651 def each_cell(&) return enum_for(:each_cell) unless block_given? each_row do |row| row.each_cell(&) end end |
#each_row {|row| ... } ⇒ Enumerator, void
Iterate over rows in this streaming sheet (O(1) memory).
: () { (StreamRow | Elements::Row) -> void } -> void : | () -> Enumerator[StreamRow | Elements::Row, void]
631 632 633 634 635 636 637 638 639 640 641 |
# File 'lib/xlsxrb.rb', line 631 def each_row return enum_for(:each_row) unless block_given? Ooxml::WorksheetParser.each_row(@sheet_xml, shared_strings: @shared_strings) do |row| if row.is_a?(Elements::Row) || row.is_a?(StreamRow) yield row else yield Xlsxrb.send(:build_row_from_raw, row) end end end |
#load ⇒ Elements::Worksheet Also known as: to_worksheet
Loads this sheet completely into an in-memory Elements::Worksheet, enabling coordinate random access (sheet), row lookups (row_at), and immutable cell updates (update_cell).
: () -> Elements::Worksheet
678 679 680 |
# File 'lib/xlsxrb.rb', line 678 def load Xlsxrb.send(:build_worksheet, @name, @sheet_xml, @shared_strings, @styles) end |