Sha256: 43b6afdae505448c2b184f9b8696e8d966d52151ec8fa22649dd9dbed6a9c003

Contents?: true

Size: 1.3 KB

Versions: 10

Compression:

Stored size: 1.3 KB

Contents

# Copyright:: Autotelik Media Ltd
# Author ::   Tom Statter
# Date ::     July 2010
# License::   
#
#
if(DataShift::Guards::jruby?)
  
  require 'java'
  require "poi-3.7-20101029.jar"
      
  # Extend the Poi classes with some syntactic sugar
  
  class Java::OrgApachePoiHssfUsermodel::HSSFSheet
    def name() 
      getSheetName
    end
    
    def num_rows
      getPhysicalNumberOfRows
    end
  
  end
  
  class Java::OrgApachePoiHssfUsermodel::HSSFRow
    
    include RubyPoiTranslations
    
    include Enumerable
        
    def []( column)
      cell_value( get_or_create_cell( column )  )
    end
    
    def []=( column, value )
      get_or_create_cell(column, value).setCellValue( poi_cell_value(value) )
    end
  
    def get_or_create_cell( column, value = nil )
      if(value)
        java_send(:getCell, [Java::int], column) || createCell(column, poi_cell_type(value))
      else
        java_send(:getCell, [Java::int], column) || java_send(:createCell, [Java::int], column)
      end
    end
    
    def idx 
      getRowNum() 
    end
    
    # Iterate over each column in the row and yield on the cell
    def each(&block) 
      cellIterator.each {|c| yield cell_value(c) }        
    end
     
    # TODO
    # for min, max and sort from enumerable need <=>
   # def <=> end
     
  end
  
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
datashift-0.16.0 lib/applications/apache_poi_extensions.rb
datashift-0.15.0 lib/applications/apache_poi_extensions.rb
datashift-0.14.0 lib/applications/apache_poi_extensions.rb
datashift-0.13.0 lib/applications/apache_poi_extensions.rb
datashift-0.12.1 lib/applications/apache_poi_extensions.rb
datashift-0.12.0 lib/applications/apache_poi_extensions.rb
datashift-0.11.1 lib/applications/apache_poi_extensions.rb
datashift-0.11.0 lib/applications/apache_poi_extensions.rb
datashift-0.10.2 lib/applications/apache_poi_extensions.rb
datashift-0.10.1 lib/applications/apache_poi_extensions.rb