You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Nicklas Ansman Giertz <ni...@wrapp.com> on 2013/04/23 22:32:23 UTC

Cells with references are not updating

Imagine I have the cell A1 and A2.
A1 contains a numeric value and A2 contains the formula "A1+10"

In the template A1 is blank which causes A2 to have the value "10".

Then in apache poi I write the number "5" to A1 but sadly A2 does't update.

I can force it to update by doing:
cell.setCellFormula(cell.getCellFormula());

After looking through the code I think it's this line that does the trick:
if(_cell.isSetV()) _cell.unsetV();

Can this clearing of pre calculated values be done automatically on all
cels that references A1?

Or if this is not possible is there a prettier solution than "refreshing"
the formula?

I'm using Apache POI 3.9 and I'm writing to an XLSX file.

Regards
Nicklas