A zero returned by FormulaRecord#getValue() means that the formula
wasn't calculated before. Did you try to evaluate the cell and ask the
value after that?
Some help on formula evaluation can be found here:
http://poi.apache.org/spreadsheet/eval.html

The text dump shows and the formula is either shared or array:

>    Ptg[0]=[Array Formula or Shared Formula]

It might be that POI doen't properly handle these type, but I can't
tell for sure without a sample file.

What is the formula string you see in Excel?

If you think it is a bug, then please create a new issue and Bugzilla
and upload the problematic file and a Java code (ideally a failing
junit test case) that demonstrates the problem.

Yegor
On Sun, Nov 6, 2011 at 2:49 AM, falsedmitri <[email protected]> wrote:
> I need to find the point in the POI code where a formula is read in from an
> excel cell. Can someone point me to this?
>
> I'm having a problem with POI with the a formula value not being calculated
> (always getting 0 in FormulaRecord.getValue()). So presumably it first has
> to read the formula before it can calculate it, but it is difficult to find
> this without knowing the internal structure of excel files.
>
> The class extends HSSFListener and so has:
>      public void processRecord(Record record) ...
>
> and the record at that point has 0 when it should have a calculated number.
>
> Looking in RecordFactoryInputStream.nextRecord() and adding a debug
> statement, it appears that the number is already calculated:
>
> *record = readNextRecord();
> if (record instanceof FormulaRecord) {
>        System.out.println ("RecordFactoryInputStream.nextRecord(); " +
> record.toString());
> }*
>
> Toggle HighlightingOpen in New WindowSelect All
>
> RecordFactoryInputStream.nextRecord(); [FORMULA]
>    .row    = 0x0003
>    .col    = 0x0002
>    .xfindex= 0x0040
>  .value       = -0.1609487366724528
>  .options   = 0x0008
>    .alwaysCalc= false
>    .calcOnLoad= false
>    .shared    = true
>  .zero      = 0xFE090003
>    Ptg[0]=[Array Formula or Shared Formula]
> row = 3
> col = 2
> .
> [/FORMULA]
>
> The output data above is a case where the formula is calculated correctly.
>
> Using 3.8 beta3.
>
> --
> View this message in context: 
> http://apache-poi.1045710.n5.nabble.com/Where-is-POI-formula-read-for-HSSF-tp4967675p4967675.html
> Sent from the POI - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to