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.



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

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



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

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)



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

def dimensions
  @dimensions ||= extract_dimensions
end

#each_cell(row_xml) ⇒ Object

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



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

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



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

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


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

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