ExcelChartSheetDefault implements ExcelChartSheet { @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())) { final Cell cell; 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 Number) { cell = row.createCell(column, CellType.NUMERIC); cell.setCellValue(((Number) 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("dd-MM-yyyy"); cell = row.createCell(column, CellType.STRING); cell.setCellValue(sdf.format((Date) value)); } else { cell = row.createCell(column, CellType.STRING); cell.setCellValue(value.toString()); } } } } } if (row.getRowNum() < 1) { cell.setCellStyle(headerStyleCell); } else { cell.setCellStyle(dataStyleCell); } } else { row.createCell(column); } } ExcelChartSheetDefault(final Workbook workbook, final String excelSheetName); @Override void writeCell(final Object value, final Row row, final int column); @Override Row createRow(final int rowNumber); @Override Row createRow(); @Override void setColumnWidth(final int collNumber, final int size); @Override Chart createChartAndLegend(); @Override ChartDataSource<?> getCategoryChartDataSource(); @Override List<ChartDataSource<Number>> getValuesChartDataSource();  }
@Test public void writeCell() throws Exception { final ExcelChartSheet excelChartSheet = new ExcelChartSheetDefault(workbook, ChartType.bar.toString()); final Row row = excelChartSheet.createRow(); excelChartSheet.writeCell(null, row, 0); excelChartSheet.writeCell(Boolean.TRUE, row, 1); excelChartSheet.writeCell("text", row, 2); excelChartSheet.writeCell(1, row, 3); Assert.assertEquals(CellType.BLANK, row.getCell(0).getCellTypeEnum()); Assert.assertEquals("Yes", row.getCell(1).getStringCellValue()); Assert.assertEquals(CellType.STRING, row.getCell(2).getCellTypeEnum()); Assert.assertEquals(CellType.NUMERIC, row.getCell(3).getCellTypeEnum()); }