Class: Roo::Excelx::SheetDoc
- Extended by:
- Forwardable
- 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, shared, options = {}) ⇒ SheetDoc
constructor
A new instance of SheetDoc.
Constructor Details
#initialize(path, relationships, shared, options = {}) ⇒ SheetDoc
Returns a new instance of SheetDoc.
10 11 12 13 14 15 |
# File 'lib/roo/excelx/sheet_doc.rb', line 10 def initialize(path, relationships, shared, = {}) super(path) @shared = shared @options = @relationships = relationships end |
Instance Method Details
#cells(relationships) ⇒ Object
17 18 19 |
# File 'lib/roo/excelx/sheet_doc.rb', line 17 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)
28 29 30 |
# File 'lib/roo/excelx/sheet_doc.rb', line 28 def dimensions @dimensions ||= extract_dimensions end |
#each_cell(row_xml) ⇒ Object
Yield each cell as Excelx::Cell to caller for given row xml
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/roo/excelx/sheet_doc.rb', line 39 def each_cell(row_xml) return [] unless row_xml row_xml.children.each do |cell_element| # If you're sure you're not going to need this hyperlinks you can discard it hyperlinks = unless @options[:no_hyperlinks] key = ::Roo::Utils.ref_to_key(cell_element['r']) hyperlinks(@relationships)[key] end yield cell_from_xml(cell_element, hyperlinks) end end |
#each_row_streaming(&block) ⇒ Object
Yield each row xml element to caller
33 34 35 |
# File 'lib/roo/excelx/sheet_doc.rb', line 33 def each_row_streaming(&block) Roo::Utils.each_element(@path, 'row', &block) end |
#hyperlinks(relationships) ⇒ Object
21 22 23 |
# File 'lib/roo/excelx/sheet_doc.rb', line 21 def hyperlinks(relationships) @hyperlinks ||= extract_hyperlinks(relationships) end |