Module: RubyPoiTranslations
- Included in:
- JExcelFile, JExcelFile, Java::OrgApachePoiHssfUsermodel::HSSFRow
- Defined in:
- lib/applications/ruby_poi_translations.rb
Instance Method Summary collapse
-
#cell_value(cell) ⇒ Object
Cell.CELL_TYPE_NUMERIC, Cell.CELL_TYPE_STRING, Cell.CELL_TYPE_FORMULA, Cell.CELL_TYPE_BLANK, Cell.CELL_TYPE_BOOLEAN, Cell.CELL_TYPE_ERROR.
-
#poi_cell_type(data) ⇒ Object
Return the suitable type for a HSSFCell from a Ruby data type.
-
#poi_cell_value(data) ⇒ Object
TODO: - properly.
Instance Method Details
#cell_value(cell) ⇒ Object
Cell.CELL_TYPE_NUMERIC, Cell.CELL_TYPE_STRING, Cell.CELL_TYPE_FORMULA, Cell.CELL_TYPE_BLANK, Cell.CELL_TYPE_BOOLEAN, Cell.CELL_TYPE_ERROR
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/applications/ruby_poi_translations.rb', line 36 def cell_value(cell) return '' unless(cell) case cell.getCellType when HSSFCell::CELL_TYPE_FORMULA then return cell.getCellFormula when HSSFCell::CELL_TYPE_NUMERIC then return cell.getNumericCellValue when HSSFCell::CELL_TYPE_STRING then return cell.getStringCellValue when HSSFCell::CELL_TYPE_BOOLEAN then return cell.getBooleanCellValue when HSSFCell::CELL_TYPE_ERROR then return cell.getErrorCellValue when HSSFCell::CELL_TYPE_BLANK then return '' end end |
#poi_cell_type(data) ⇒ Object
Return the suitable type for a HSSFCell from a Ruby data type
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/applications/ruby_poi_translations.rb', line 66 def poi_cell_type(data) if data.is_a?(Numeric) HSSFCell::CELL_TYPE_NUMERIC elsif data.nil? HSSFCell::CELL_TYPE_BLANK elsif data.is_a?(TrueClass) || data.is_a?(FalseClass) HSSFCell::CELL_TYPE_BOOLEAN else HSSFCell::CELL_TYPE_STRING end # HSSFCell::CELL_TYPE_FORMULA end |
#poi_cell_value(data) ⇒ Object
TODO: - properly
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/applications/ruby_poi_translations.rb', line 54 def poi_cell_value(data) case data when BigDecimal data.to_f when Numeric, TrueClass, FalseClass data else data.to_s end end |