AbstractExcelSheet implements ExcelSheet { @Override public void writeCell(final Object value, final Row row, final int column) { if (value != null && !((value instanceof List || value instanceof Set) && ((Collection) value).isEmpty())) { if (value instanceof String) { cell = row.createCell(column, CellType.STRING); cell.setCellValue((String) value); } else { if (value instanceof Integer) { cell = row.createCell(column, CellType.NUMERIC); cell.setCellValue((Integer) value); } else { if (value instanceof BigDecimal) { cell = row.createCell(column, CellType.NUMERIC); cell.setCellValue(((BigDecimal) value).doubleValue()); } else { if (value instanceof Boolean) { cell = row.createCell(column, CellType.BOOLEAN); cell.setCellValue(((Boolean) value) ? "Yes" : "No"); } else { if (value instanceof Date) { final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); cell = row.createCell(column); cell.setCellValue(sdf.format((Date) value)); } else { cell = row.createCell(column, CellType.STRING); cell.setCellValue(value.toString()); } } } } } cell.setCellStyle(dataStyleCell); } else { row.createCell(column); } } AbstractExcelSheet(final Workbook workbook); @Override void writeCell(final Object value, final Row row, final int column); void writeCellLink(final Object value, final Row row, final int column,
                              final String sheetName, final int rowNumber);  }
@Test public void writeCell() throws Exception { final Workbook workbook = new XSSFWorkbook(); final ExcelSheet excelSheet = new MockExcelSheet(workbook); final Sheet sheet = workbook.createSheet("sheet"); final Row row = sheet.createRow(0); excelSheet.writeCell(null, row, 0); excelSheet.writeCell(Boolean.TRUE, row, 1); excelSheet.writeCell("text", row, 2); excelSheet.writeCell(1, row, 3); Assert.assertEquals(CellType.BLANK, row.getCell(0).getCellType()); Assert.assertEquals("Yes", row.getCell(1).getStringCellValue()); Assert.assertEquals(CellType.STRING, row.getCell(2).getCellType()); Assert.assertEquals(CellType.NUMERIC, row.getCell(3).getCellType()); }