Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
72:custom_reports_references_poijava [2019/03/08 19:18] – created ext-bkkr | 72:custom_reports_references_poijava [2024/02/15 00:00] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== POI Javascript Wrapper Functions ====== | ====== POI Javascript Wrapper Functions ====== | ||
+ | |||
+ | These functions can be used to retrieve values from an Excel file using the Java POI library. | ||
+ | |||
+ | < | ||
+ | function getNumericValue(sheet, | ||
+ | Row = sheet.getRow(row); | ||
+ | if (Row != null) { | ||
+ | Cell = Row.getCell(col); | ||
+ | if (Cell != null) { | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | } | ||
+ | function getStringValue(sheet, | ||
+ | Row = sheet.getRow(row); | ||
+ | Cell = Row.getCell(col); | ||
+ | if (Cell != null) { | ||
+ | if (Cell.getCellType() == Cell.CELL_TYPE_STRING) { | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | } | ||
+ | function getDateValue(sheet, | ||
+ | Row = sheet.getRow(row); | ||
+ | Cell = Row.getCell(col); | ||
+ | if (Cell != null) { | ||
+ | if ((Cell.getCellType() == Cell.CELL_TYPE_NUMERIC) | ||
+ | || (Cell.getCellType() == Cell.CELL_TYPE_FORMULA)) { | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | } | ||
+ | /* taken vom http:// | ||
+ | title=Extracting_Excel_data_with_Apache_POI_and_Rhino */ | ||
+ | function cellValue(sheet, | ||
+ | row = sheet.getRow(CellRow); | ||
+ | if (row != null) { | ||
+ | cell = row.getCell(CellCol); | ||
+ | if (cell != null) { | ||
+ | var t = cell.cellType; | ||
+ | if (t == Cell.CELL_TYPE_NUMERIC) { | ||
+ | if (DateUtil.isCellDateFormatted(cell)) return new | ||
+ | | ||
+ | else return cell.numericCellValue + 0.0; | ||
+ | } | ||
+ | if (t == Cell.CELL_TYPE_STRING) return cell.stringCellValue + ''; | ||
+ | if (t == Cell.CELL_TYPE_FORMULA) { | ||
+ | try { | ||
+ | if (DateUtil.isCellDateFormatted(cell)) return new | ||
+ | | ||
+ | else return cell.numericCellValue + 0.0; | ||
+ | } catch(err) { } | ||
+ | try { return cell.stringCellValue + ''; | ||
+ | try { return cell.numericCellValue + 0.0; } catch(err) { } | ||
+ | try { return !!cell.booleanCellValue; | ||
+ | try { return cell.errorCellValue + 0; } catch(err) { } | ||
+ | | ||
+ | } | ||
+ | if (t == Cell.CELL_TYPE_BLANK) return ''; | ||
+ | if (t == Cell.CELL_TYPE_BOOLEAN) return !!cell.booleanCellValue; | ||
+ | if (t == Cell.CELL_TYPE_ERROR) return cell.errorCellValue + 0; | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | } | ||
+ | function isCellEmpty(sheet, | ||
+ | Row = sheet.getRow(row); | ||
+ | if (Row != null) { | ||
+ | Cell = Row.getCell(col); | ||
+ | if (Cell != null) { | ||
+ | if (Cell.getCellType() != Cell.CELL_TYPE_BLANK) { | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | } | ||
+ | </ | ||