Class: Roo::Excelx::SheetDoc
- Defined in:
- lib/roo/excelx/sheet_doc.rb
Instance Method Summary collapse
- #cells(relationships) ⇒ Object
-
#dimensions ⇒ Object
Get the dimensions for the sheet.
-
#each_cell(row_xml) ⇒ Object
Yield each cell as Excelx::Cell to caller for given row xml.
-
#each_row_streaming(&block) ⇒ Object
Yield each row xml element to caller.
- #hyperlinks(relationships) ⇒ Object
-
#initialize(path, relationships, styles, shared_strings, workbook) ⇒ SheetDoc
constructor
A new instance of SheetDoc.
Constructor Details
#initialize(path, relationships, styles, shared_strings, workbook) ⇒ SheetDoc
Returns a new instance of SheetDoc.
5 6 7 8 9 10 11 |
# File 'lib/roo/excelx/sheet_doc.rb', line 5 def initialize(path, relationships, styles, shared_strings, workbook) super(path) @relationships = relationships @styles = styles @shared_strings = shared_strings @workbook = workbook end |
Instance Method Details
#cells(relationships) ⇒ Object
13 14 15 |
# File 'lib/roo/excelx/sheet_doc.rb', line 13 def cells(relationships) @cells ||= extract_cells(relationships) end |
#dimensions ⇒ Object
Get the dimensions for the sheet. This is the upper bound of cells that might be parsed. (the document may be sparse so cell count is only upper bound)
24 25 26 |
# File 'lib/roo/excelx/sheet_doc.rb', line 24 def dimensions @dimensions ||= extract_dimensions end |
#each_cell(row_xml) ⇒ Object
Yield each cell as Excelx::Cell to caller for given row xml
35 36 37 38 39 40 41 |
# File 'lib/roo/excelx/sheet_doc.rb', line 35 def each_cell(row_xml) return [] unless row_xml row_xml.children.each do |cell_element| key = ::Roo::Utils.ref_to_key(cell_element['r']) yield cell_from_xml(cell_element, hyperlinks(@relationships)[key]) end end |
#each_row_streaming(&block) ⇒ Object
Yield each row xml element to caller
29 30 31 |
# File 'lib/roo/excelx/sheet_doc.rb', line 29 def each_row_streaming(&block) Roo::Utils.each_element(@path, 'row', &block) end |
#hyperlinks(relationships) ⇒ Object
17 18 19 |
# File 'lib/roo/excelx/sheet_doc.rb', line 17 def hyperlinks(relationships) @hyperlinks ||= extract_hyperlinks(relationships) end |