Sha256: cda320c30ce933ef1703fb34deed8f65450c1af37bb06b7e444ec25be5211d18

Contents?: true

Size: 759 Bytes

Versions: 2

Compression:

Stored size: 759 Bytes

Contents

module POI
  class Rows
    include Enumerable
    
    def initialize(worksheet)
      @worksheet = worksheet
      @poi_worksheet = worksheet.poi_worksheet
    end

    def [](index)
      Row.new(@poi_worksheet.getRow(index))
    end

    def size 
      @poi_worksheet.getPhysicalNumberOfRows 
    end

    def each
      it = @poi_worksheet.rowIterator
      yield Row.new(it.next) while it.hasNext
    end
  end

  class Row
    def initialize(row)
      @row = row
    end
    
    def [](index)
      return nil if poi_row.nil?
      Cell.new(poi_row.getCell(index))
    end

    def cells
      Cells.new(self)
    end

    def index
      return nil if poi_row.nil?
      poi_row.getRowNum
    end    

    def poi_row
      @row
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jruby-poi-0.6.1 lib/poi/workbook/row.rb
jruby-poi-0.6.0 lib/poi/workbook/row.rb