mirror of https://github.com/apache/poi.git
add date test
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1891878 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cd7b6b7197
commit
925688a454
|
@ -1386,6 +1386,26 @@ public abstract class BaseTestCell {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void setCellFormulaWithDateArithmetic() throws IOException {
|
||||
try (Workbook wb = _testDataProvider.createWorkbook()) {
|
||||
Cell cellA1 = getInstance(wb);
|
||||
cellA1.setCellFormula("B1+1");
|
||||
|
||||
LocalDate date = LocalDate.parse("2021-07-31");
|
||||
Cell cellB1 = cellA1.getRow().createCell(1);
|
||||
cellB1.setCellValue(date);
|
||||
|
||||
assertEquals(CellType.FORMULA, cellA1.getCellType());
|
||||
assertEquals(CellType.NUMERIC, cellA1.getCachedFormulaResultType());
|
||||
|
||||
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
|
||||
CellValue valueA1 = fe.evaluate(cellA1);
|
||||
assertEquals(CellType.NUMERIC, valueA1.getCellType());
|
||||
assertEquals(DateUtil.getExcelDate(date.plusDays(1)), valueA1.getNumberValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void setCellType_FORMULA_onAnArrayFormulaCell_doesNothing() throws IOException {
|
||||
try (Workbook wb = _testDataProvider.createWorkbook()) {
|
||||
|
|
Loading…
Reference in New Issue