diff --git a/src/java/org/apache/poi/ss/formula/atp/ArgumentsEvaluator.java b/src/java/org/apache/poi/ss/formula/atp/ArgumentsEvaluator.java index 012333f0b1..fa5d50aee6 100644 --- a/src/java/org/apache/poi/ss/formula/atp/ArgumentsEvaluator.java +++ b/src/java/org/apache/poi/ss/formula/atp/ArgumentsEvaluator.java @@ -86,7 +86,9 @@ final class ArgumentsEvaluator { AreaEvalBase area = (AreaEvalBase) arg; for (int i = area.getFirstRow(); i <= area.getLastRow(); i++) { for (int j = area.getFirstColumn(); j <= area.getLastColumn(); j++) { - valuesList.add(evaluateDateArg(area.getValue(i, j), i, j)); + // getValue() is replaced with getAbsoluteValue() because loop variables i, j are + // absolute indexes values, but getValue() works with relative indexes values + valuesList.add(evaluateDateArg(area.getAbsoluteValue(i, j), i, j)); } } double[] values = new double[valuesList.size()]; diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java index ee07c4ef0a..3280a9121b 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -3078,4 +3078,17 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { assertEquals(70, sheet.getLastRowNum()); assertEquals(70, sheet.getRow(sheet.getLastRowNum()).getRowNum()); } + + @Test + public void testWorkdayFunction() throws IOException { + XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("59106.xlsx"); + XSSFSheet sheet = workbook.getSheet("Test"); + Row row = sheet.getRow(1); + Cell cell = row.getCell(0); + DataFormatter form = new DataFormatter(); + FormulaEvaluator evaluator = cell.getSheet().getWorkbook().getCreationHelper().createFormulaEvaluator(); + String result = form.formatCellValue(cell, evaluator); + + assertEquals("09 Mar 2016", result); + } } diff --git a/test-data/spreadsheet/59106.xlsx b/test-data/spreadsheet/59106.xlsx new file mode 100644 index 0000000000..e47845ad6f Binary files /dev/null and b/test-data/spreadsheet/59106.xlsx differ