You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by 马鸣杰 <vi...@sparkleconsulting.com> on 2011/08/25 09:31:31 UTC

how to read the formula cell in "user event mode"?

Hi all,

I am trying to read a very big excel file, so I have to user “user event
mode”. 

But when reading some formula Record (for example, in cell B2, the formula
is ‘=A2’, A2 is a simple cell with text like ‘test’), the API works in
unexpected way. 

My code is:

case FormulaRecord.sid:

           FormulaRecord frec = (FormulaRecord) record;

           thisRow = frec.getRow();

           thisColumn = frec.getColumn();

 

           if (outputFormulaValues) {

              if (Double.isNaN(frec.getValue())) {

                  outputNextStringRecord = true;

                  nextRow = frec.getRow();

                  nextColumn = frec.getColumn();

              } else {

                  thisStr = formatListener.formatNumberDateCell(frec);

              }

           } else {

              thisStr = HSSFFormulaParser.toFormulaString(stubWorkbook,
frec.getParsedExpression());

           }

           break;

 

Please give me some advice, thanks!


Re: how to read the formula cell in "user event mode"?

Posted by Nick Burch <ni...@alfresco.com>.
On Thu, 25 Aug 2011, 马鸣杰 wrote:
> I am trying to read a very big excel file, so I have to user “user event 
> mode”.
>
> But when reading some formula Record (for example, in cell B2, the formula
> is ‘=A2’, A2 is a simple cell with text like ‘test’), the API works in
> unexpected way.

As you don't specify what's unexpected about how it behaves I can't be all 
that helpful, but I'd suggest you take a look at ExcelExtractor in Apache 
Tika, which is a good example of using hte event user model from outside 
of the POI codebase itself:
http://svn.apache.org/repos/asf/tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/microsoft/ExcelExtractor.java

Nick