Sha256: b6e103ca57100573f20389c180781b977f1fbd87c30c50f0de1750ef23756a06
Contents?: true
Size: 1.22 KB
Versions: 2
Compression:
Stored size: 1.22 KB
Contents
module POI class Worksheets include Enumerable def initialize(workbook) @workbook = workbook @poi_workbook = workbook.poi_workbook end def [](index) worksheet = case when index.kind_of?(Numeric) @poi_workbook.getSheetAt(index) else @poi_workbook.getSheet(index) end Worksheet.new(worksheet) end def size @poi_workbook.getNumberOfSheets end def each (0...size).each { |i| yield Worksheet.new(@poi_workbook.getSheetAt(i)) } end end class Worksheet def initialize(worksheet = nil) @worksheet = worksheet end def name @worksheet.getSheetName end def rows Rows.new(self) end # Accepts a Fixnum or a String as the row_index # # row_index as Fixnum - returns the 0-based row # row_index as String - assumes a cell reference within this sheet and returns the cell value for that reference def [](row_index) if Fixnum === row_index rows[row_index] else ref = org.apache.poi.ss.util.CellReference.new(row_index) rows[ref.getRow][ref.getCol].value end end def poi_worksheet @worksheet end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jruby-poi-0.6.1 | lib/poi/workbook/worksheet.rb |
jruby-poi-0.6.0 | lib/poi/workbook/worksheet.rb |