Hi,
I love the concept - build beautiful Excel templates - use NPOI to populate with data, then create a copy and return to user, but I have hit a bump.
I have an Excel file, written to by NPOI (v2.0.6). The Excel file has a pivot table and formulas built into it. The formulas reference the data written by NPOI.
My code then exports a copy of the file with the fresh data in it and gives it to the user. When the user opens it using Excel 2010, the formulas have not refreshed, and even pressing F9 does not refresh them. I have to actually click into the formula and hit 'Enter' for it to refresh.
Also, my pivot table doesn't refresh upon opening the file, even after setting it to do so in the options for the pivot table.
I am trying to build code that will work with any template I create - so using NPOI to create and / or refresh specific cells or pivot tables will not work for me - every template will be different. Is there a setting in either NPOI or Excel that will help me out here? Am I missing something?
Anyone else with similar issues?
Thanks in advance for a great tool, Tony, and to anyone who is able to help!
Comments: ** Comment from web user: mel0nc0lly **
I love the concept - build beautiful Excel templates - use NPOI to populate with data, then create a copy and return to user, but I have hit a bump.
I have an Excel file, written to by NPOI (v2.0.6). The Excel file has a pivot table and formulas built into it. The formulas reference the data written by NPOI.
My code then exports a copy of the file with the fresh data in it and gives it to the user. When the user opens it using Excel 2010, the formulas have not refreshed, and even pressing F9 does not refresh them. I have to actually click into the formula and hit 'Enter' for it to refresh.
Also, my pivot table doesn't refresh upon opening the file, even after setting it to do so in the options for the pivot table.
I am trying to build code that will work with any template I create - so using NPOI to create and / or refresh specific cells or pivot tables will not work for me - every template will be different. Is there a setting in either NPOI or Excel that will help me out here? Am I missing something?
Anyone else with similar issues?
Thanks in advance for a great tool, Tony, and to anyone who is able to help!
Comments: ** Comment from web user: mel0nc0lly **
Hi,
For what it's worth, the following page solved this for me:
http://stackoverflow.com/questions/24088737/how-to-re-calculate-a-cells-formula
Specifically this code:
```
if(wb is XSSFWorkbook) {
XSSFFormulaEvaluator.EvaluateAllFormulaCells(wb);
} else {
HSSFFormulaEvaluator.EvaluateAllFormulaCells(wb);
}
```