Class: Roo::Excelx::SheetDoc

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

Instance Method Summary collapse

Constructor Details

#initialize(path, relationships, styles, shared_strings, workbook, options = {}) ⇒ SheetDoc

Returns a new instance of SheetDoc.



5
6
7
8
9
10
11
12
# File 'lib/roo/excelx/sheet_doc.rb', line 5

def initialize(path, relationships, styles, shared_strings, workbook, options = {})
  super(path)
  @options = options
  @relationships = relationships
  @styles = styles
  @shared_strings = shared_strings
  @workbook = workbook
end

Instance Method Details

#cells(relationships) ⇒ Object



14
15
16
# File 'lib/roo/excelx/sheet_doc.rb', line 14

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)



25
26
27
# File 'lib/roo/excelx/sheet_doc.rb', line 25

def dimensions
  @dimensions ||= extract_dimensions
end

#each_cell(row_xml) ⇒ Object

Yield each cell as Excelx::Cell to caller for given row xml



36
37
38
39
40
41
42
# File 'lib/roo/excelx/sheet_doc.rb', line 36

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



30
31
32
# File 'lib/roo/excelx/sheet_doc.rb', line 30

def each_row_streaming(&block)
  Roo::Utils.each_element(@path, 'row', &block)
end


18
19
20
# File 'lib/roo/excelx/sheet_doc.rb', line 18

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