Josef
Josef

Reputation: 63

Apache POI Excel Formula entering @ Symbols

i generate an excel document with my application. I try to set a formula like this:

cell.setCellFormula("ANZAHL2(B10:B37");

What gets generated in my Excel-File is this:

=@ANZAHL2(B10:B37)

Where does the @-Symbol come from?

I have other cells where i just sum up different cell-values, and these work just fine

cell.setCellFormula("A5+A10");

gives me

=(A5+A10)

I found this thread Apache POI Excel Formula entering @ Symbols where they don't belong but the solution provided to put a '_xlfn.' in front of the aggregate-function doesnt work for me.

cell.setCellFormula("_xlfn.ANZAHL2(B10:B37");

Thanks in advance!

Upvotes: 0

Views: 904

Answers (1)

Axel Richter
Axel Richter

Reputation: 61870

Microsoft Excel never stores localized formula strings. It always stores en_US formula strings. So use cell.setCellFormula("COUNTA(B10:B37)"); to make it work.

Cell.setCellFormula always sets the formula string as stored directly into the file.

The Excel GUI will change that formula to the German version =ANZAHL2(B10:B37) after it had read the en_US formula string from the file storage.

Upvotes: 3

Related Questions