*/
public void setCellValue(Date value)
{
+ if(value == null) {
+ setCellType(CellType.BLANK);
+ return;
+ }
+
setCellValue(HSSFDateUtil.getExcelDate(value, _book.getWorkbook().isUsing1904DateWindowing()));
}
*/
public void setCellValue(Calendar value)
{
+ if(value == null) {
+ setCellType(CellType.BLANK);
+ return;
+ }
+
setCellValue( HSSFDateUtil.getExcelDate(value, _book.getWorkbook().isUsing1904DateWindowing()) );
}
assertEquals("???<>\t\n\u00a0 &\"POI\'\u2122", wb2.getSheetAt(0).getRow(0).getCell(0).getStringCellValue());
wb2.close();
}
-
- @Test
- public void testSetNullValues() throws IOException {
- Workbook wb = _testDataProvider.createWorkbook();
- Cell cell = wb.createSheet("test").createRow(0).createCell(0);
-
- cell.setCellValue((Calendar)null);
- cell.setCellValue((Date)null);
- cell.setCellValue((String)null);
- cell.setCellValue((RichTextString) null);
- cell.setCellValue((String)null);
-
- wb.close();
- }
}
}
}
+ @Test
+ public void test62216() throws IOException {
+ try (Workbook wb = _testDataProvider.createWorkbook()) {
+ Cell instance = wb.createSheet().createRow(0).createCell(0);
+ String formula = "2";
+ instance.setCellFormula(formula);
+ instance.setCellErrorValue(FormulaError.NAME.getCode());
+
+ assertEquals(formula, instance.getCellFormula());
+ }
+ }
+
+ @Test
+ public void testSetNullValues() throws IOException {
+ Workbook wb = _testDataProvider.createWorkbook();
+ Cell cell = wb.createSheet("test").createRow(0).createCell(0);
+
+ cell.setCellValue((Calendar)null);
+ assertEquals(CellType.BLANK, cell.getCellType());
+ assertEquals("", cell.getStringCellValue());
+
+ cell.setCellValue((Date)null);
+ assertEquals(CellType.BLANK, cell.getCellType());
+ assertEquals("", cell.getStringCellValue());
+
+ cell.setCellValue((String)null);
+ assertEquals(CellType.BLANK, cell.getCellType());
+ assertEquals("", cell.getStringCellValue());
+
+ assertEquals(CellType.BLANK, cell.getCellType());
+ assertEquals("", cell.getStringCellValue());
+
+ cell.setCellValue((RichTextString) null);
+ assertEquals(CellType.BLANK, cell.getCellType());
+ assertEquals("", cell.getStringCellValue());
+
+ cell.setCellValue((String)null);
+ assertEquals(CellType.BLANK, cell.getCellType());
+ assertEquals("", cell.getStringCellValue());
+
+ wb.close();
+ }
+
@Test
public void testFormulaSetValueDoesNotChangeType() throws IOException {
try (Workbook wb = _testDataProvider.createWorkbook()) {