Bug 68233 - addDataField(DataConsolidateFunction,int,String,String)@XSSFPivotTable can build a wrong mapping
Summary: addDataField(DataConsolidateFunction,int,String,String)@XSSFPivotTable can bu...
Status: RESOLVED WONTFIX
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 5.3.x-dev
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-11-27 02:30 UTC by zhonghao
Modified: 2024-02-25 20:21 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description zhonghao 2023-11-27 02:30:22 UTC
The code is as follows:

 private void addDataField(DataConsolidateFunction function, int columnIndex, String valueFieldName, String valueFormat) {
 ...
  dataField.setSubtotal(STDataConsolidateFunction.Enum.forInt(function.getValue()));
}

I noticed that an early version of NPOI is quite similar:

private void AddDataField(DataConsolidateFunction function, int columnIndex, Str...
   dataField.subtotal = (ST_DataConsolidateFunction)(function.Value);
}

However, it is revised to:

private void AddDataField(DataConsolidateFunction function, int columnIndex, Str...
   dataField.subtotal = (ST_DataConsolidateFunction)(function.Value-1);
}

The commit is as follows:

https://github.com/nissl-lab/npoi/commit/1e1e7f07dc04ca17a96819e015df6dcded37b399
Comment 1 PJ Fanning 2023-11-27 10:27:13 UTC
Please provide a real world example that proves the code is incorrect. We are not going to just copy what NPOI do. That NPOI commit has no tests to verify the change.
Comment 2 Dominik Stadler 2024-02-25 20:21:16 UTC
No update for some time, thus closing this for now as we likely won't fix anything until it is clear that this is a real problem.

Furthermore when looking at STDataConsolidateFunction.Enum and DataConsolidateFunction, I think the indices of the two enums are equal, so it would even introduce a bug if we would apply this change. 

Not sure if things are different for NPOI, but you might check if the change is even useful there or actually introduced a bug.