Class: Roo::Excelx::SheetDoc
- Extended by:
- Forwardable
- Defined in:
- lib/roo/excelx/sheet_doc.rb
Constant Summary
Constants inherited from Extractor
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.
12 13 14 15 16 17 |
# File 'lib/roo/excelx/sheet_doc.rb', line 12 def initialize(path, relationships, shared, = {}) super(path) @shared = shared @options = @relationships = relationships end |
Instance Method Details
#cells(relationships) ⇒ Object
19 20 21 |
# File 'lib/roo/excelx/sheet_doc.rb', line 19 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)
35 36 37 |
# File 'lib/roo/excelx/sheet_doc.rb', line 35 def dimensions @dimensions ||= extract_dimensions end |
#each_cell(row_xml) ⇒ Object
Yield each cell as Excelx::Cell to caller for given row xml
46 47 48 49 50 51 52 53 54 |
# File 'lib/roo/excelx/sheet_doc.rb', line 46 def each_cell(row_xml) return [] unless row_xml row_xml.children.each do |cell_element| coordinate = ::Roo::Utils.extract_coordinate(cell_element["r"]) hyperlinks = hyperlinks(@relationships)[coordinate] yield cell_from_xml(cell_element, hyperlinks, coordinate) end end |
#each_row_streaming(&block) ⇒ Object
Yield each row xml element to caller
40 41 42 |
# File 'lib/roo/excelx/sheet_doc.rb', line 40 def each_row_streaming(&block) Roo::Utils.each_element(@path, 'row', &block) end |
#hyperlinks(relationships) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/roo/excelx/sheet_doc.rb', line 23 def hyperlinks(relationships) # If you're sure you're not going to need this hyperlinks you can discard it @hyperlinks ||= if @options[:no_hyperlinks] || !relationships.include_type?("hyperlink") {} else extract_hyperlinks(relationships) end end |