@Override public IRow readRow() { SheetData vData = getLocalData(); int vRowIndex = vData.getCurrentIndex(); if (vRowIndex < vData.getRowCount()) { Row vRow = vData.getSheet().getRow(vRowIndex); String[] vTitles = vData.getTitles(); Cell[] vValues = new Cell[vTitles.length]; for (int i = 0; i < vTitles.length; ++i) { Cell vCell = vRow.getCell(i, MissingCellPolicy.CREATE_NULL_AS_BLANK); vValues[i] = vCell; } vData.setCurrentIndex(vRowIndex + 1); return new RowExcelImpl(vRowIndex, vTitles, vValues); } // read over, remove the local data removeLocalData(); return null; }
private void setCellValue(final Object value, final int columnIndex) { Cell cell = currentExcelRow.getCell( sheetConfig.columnOrigin() + columnIndex, MissingCellPolicy.CREATE_NULL_AS_BLANK ); sheetConfig.cellStyler().style(cell); if(value == null) { return; } // numbers if (value instanceof Integer) { cell.setCellValue(Double.valueOf(((Integer) value).intValue())); } else if (value instanceof Long) { cell.setCellValue(Double.valueOf(((Long) value).longValue())); } else if (value instanceof Float) { cell.setCellValue(Double.valueOf(((Float) value).floatValue())); } else if (value instanceof BigDecimal) { cell.setCellValue(((BigDecimal) value).doubleValue()); } else if (value instanceof Double) { cell.setCellValue((Double) value); } // other types else if (value instanceof Boolean) { cell.setCellValue(((Boolean) value).booleanValue()); } else if (value instanceof Calendar) { cell.setCellValue((Calendar) value); } else if (value instanceof Date) { cell.setCellValue((Date) value); } else if (value instanceof String) { cell.setCellValue((String) value); } else { cell.setCellValue(value.toString()); } }
@Override public PoiCell getCell(int col) { org.apache.poi.ss.usermodel.Cell poiCell = poiRow.getCell(col, MissingCellPolicy.CREATE_NULL_AS_BLANK); return new PoiCell(this, poiCell); }
/** * Not supported */ @Override public MissingCellPolicy getMissingCellPolicy() { throw new UnsupportedOperationException(); }
/** * Not supported */ @Override public void setMissingCellPolicy(MissingCellPolicy missingCellPolicy) { throw new UnsupportedOperationException(); }
public static Cell getCell(Row row, int col, MissingCellPolicy mcp) { if (row == null) { return null; } return row.getCell(col, mcp); }