Class: Roo::Excelx::SheetDoc

Inherits:
Extractor show all
Extended by:
Forwardable
Defined in:
lib/roo/excelx/sheet_doc.rb

Instance Method Summary collapse

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, options = {})
  super(path)
  @shared = shared
  @options = 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

#dimensionsObject

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
# 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|
    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



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


21
22
23
# File 'lib/roo/excelx/sheet_doc.rb', line 21

def hyperlinks(relationships)
  @hyperlinks ||= extract_hyperlinks(relationships)
end