Bug 59106

Summary: [PATCH] WorkdayFunction does not read correctly the area with holidays to calculate work days
Product: POI Reporter: Artem Bondar <bondaraw>
Component: XSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: critical CC: bondaraw
Priority: P2 Keywords: PatchAvailable
Version: 3.13-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: Excel file with data for testing and Unit test
Patch file
Unit test
Excel document with tests data

Description Artem Bondar 2016-03-03 10:33:11 UTC
Created attachment 33618 [details]
Excel file with data for testing and Unit test

Package: org.apache.poi.ss.formula.atp
Class: ArgumentsEvaluator
Method: evaluateDatesArg(ValueEval arg, int srcCellRow, int srcCellCol);

Here is the code:

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));
    }
}
i and j stored absolute path.

Method getValue() used relative path. Here is code:

public final ValueEval getValue(int row, int col) {
    return getRelativeValue(row, col);
}

WorkdayFunction does not read correctly the area with holidays to calculate work days. We have debugged it and found that you are using a relating path (area.getValue()), but you need to use an absolute path (area.getAbsoluteValue()).

An excel file with data for testing and Unit test is attached.
Please fix it.
Comment 1 Artem Bondar 2016-03-12 20:38:22 UTC
Created attachment 33660 [details]
Patch file
Comment 2 Artem Bondar 2016-03-12 20:38:44 UTC
Created attachment 33661 [details]
Unit test
Comment 3 Artem Bondar 2016-03-12 20:40:39 UTC
Created attachment 33662 [details]
Excel document with tests data
Comment 4 Dominik Stadler 2016-07-17 21:20:18 UTC
Applied in r1753125, thanks for the patch!