59106: WorkdayFunction does not read the area with holidays correctly to calculate work days

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1753125 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2016-07-17 21:18:27 +00:00
parent 29b21a82f7
commit 0bf845e0cc
3 changed files with 16 additions and 1 deletions

View File

@ -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()];

View File

@ -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);
}
}

Binary file not shown.