aboutsummaryrefslogtreecommitdiffstats
path: root/poi/src
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2021-07-29 18:22:18 +0000
committerPJ Fanning <fanningpj@apache.org>2021-07-29 18:22:18 +0000
commit925688a454c22770c0b6c41b1ff4b83620382d2c (patch)
tree5a37e29d5fdaf0e95f7b49e340f9af5fa3a0e806 /poi/src
parentcd7b6b71972d00613da4a7f2672916c1df70f531 (diff)
downloadpoi-925688a454c22770c0b6c41b1ff4b83620382d2c.tar.gz
poi-925688a454c22770c0b6c41b1ff4b83620382d2c.zip
add date test
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1891878 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi/src')
-rw-r--r--poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestCell.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestCell.java b/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestCell.java
index d8a54cfa54..944f46dd1c 100644
--- a/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestCell.java
+++ b/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestCell.java
@@ -1387,6 +1387,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()) {
Cell cell = getInstance(wb);