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
707 708 709 710 711 712 |
# File 'lib/xlsxrb.rb', line 707 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)
700 701 702 |
# File 'lib/xlsxrb.rb', line 700 def name @name end |
Instance Method Details
#each ⇒ void #each ⇒ Enumerator[StreamRow | Elements::Row, void]
Default Enumerable iteration iterates rows in the streaming sheet.
: () { (StreamRow | Elements::Row) -> void } -> void : () -> Enumerator[StreamRow | Elements::Row, void]
758 759 760 |
# File 'lib/xlsxrb.rb', line 758 def each(&) each_row(&) end |
#each_cell ⇒ void #each_cell ⇒ Enumerator[Elements::Cell, void]
Iterate over all cells across rows continuously (O(1) memory).
: () { (Elements::Cell) -> void } -> void : () -> Enumerator[Elements::Cell, void]
742 743 744 745 746 747 748 |
# File 'lib/xlsxrb.rb', line 742 def each_cell(&) return enum_for(:each_cell) unless block_given? each_row do |row| row.each_cell(&) end end |
#each_row ⇒ void #each_row ⇒ Enumerator[StreamRow | Elements::Row, void]
Iterate over rows in this streaming sheet (O(1) memory).
: () { (StreamRow | Elements::Row) -> void } -> void : () -> Enumerator[StreamRow | Elements::Row, void]
722 723 724 725 726 727 728 729 730 731 732 |
# File 'lib/xlsxrb.rb', line 722 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
769 770 771 |
# File 'lib/xlsxrb.rb', line 769 def load Xlsxrb.send(:build_worksheet, @name, @sheet_xml, @shared_strings, @styles) end |