Bug 17525 - FormulaRecord event is never triggered
Summary: FormulaRecord event is never triggered
Status: RESOLVED INVALID
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 1.5
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-02-28 13:21 UTC by Kjeld Poulsen
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kjeld Poulsen 2003-02-28 13:21:59 UTC
I try to use HSSFEvent model to take input from an xls file in a streaming
manner, where the eventmodel impl. in poi match my purpose, however I never
get a RecordEvent FormulaRecord, but my sheet has a lot of formulars.

This is som testcode that also fail, produced from the example in the example 
package:
START:

package dk.bording.demo.excel;
import org.apache.poi.hssf.eventmodel.HSSFEventFactory;
import org.apache.poi.hssf.eventmodel.HSSFListener;
import org.apache.poi.hssf.eventmodel.HSSFRequest;
import org.apache.poi.hssf.record.*;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;


public class EventExample implements HSSFListener {
    private SSTRecord sstrec;


    public void processRecord(Record record)
    {
        switch (record.getSid())
        {
            // the BOFRecord can represent either the beginning of a sheet or 
the workbook
            case BOFRecord.sid:
                BOFRecord bof = (BOFRecord) record;
                if (bof.getType() == bof.TYPE_WORKBOOK)
                {
                    System.out.println("Encountered workbook");
                    // assigned to the class level member
                } else if (bof.getType() == bof.TYPE_WORKSHEET)
                {
                    System.out.println("Encountered sheet reference");
                }
                break;
            case BoundSheetRecord.sid:
                BoundSheetRecord bsr = (BoundSheetRecord) record;
                System.out.println("New sheet named: " + bsr.getSheetname());
                break;
            case RowRecord.sid:
                RowRecord rowrec = (RowRecord) record;
                System.out.println("Row found, first column at "
                        + rowrec.getFirstCol() + " last column at " + 
rowrec.getLastCol());
                break;
            case NumberRecord.sid:
                NumberRecord numrec = (NumberRecord) record;
                System.out.println("Cell found with value " + numrec.getValue()
                        + " at row " + numrec.getRow() + " and column " + 
numrec.getColumn());
                break;
                // SSTRecords store a array of unique strings used in Excel.
            case SSTRecord.sid:
                sstrec = (SSTRecord) record;
                for (int k = 0; k < sstrec.getNumUniqueStrings(); k++)
                {
                    System.out.println("String table value " + k + " = " + 
sstrec.getString(k));
                }
                break;
            case LabelSSTRecord.sid:
                LabelSSTRecord lrec = (LabelSSTRecord) record;
                System.out.println("String cell found with value "
                        + sstrec.getString(lrec.getSSTIndex()));
                break;
            case ExtendedFormatRecord.sid:
                 System.out.println("ExtendedFormatRecord" );
                 break;
            case FormatRecord.sid:
                 System.out.println("FormatRecord" );
                 break;
            case FontRecord.sid:
                 System.out.println("FontRecord");
                 break;
            case FormulaRecord.sid:
                 // This block is never called !!!!!!!!!!!
                 System.out.println("Calculation:" + ((FormulaRecord)
record).getValue() );
                 break;
            default: //System.out.println("Default:" + record.toString() ) ;
        }
    }


    public static void main(String[] args) throws IOException
    {
        // create a new file input stream with the input file specified
        // at the command line
        FileInputStream fin = new FileInputStream(args[0]);
        // create a new org.apache.poi.poifs.filesystem.Filesystem
        POIFSFileSystem poifs = new POIFSFileSystem(fin);
        // get the Workbook (excel part) stream in a InputStream
        InputStream din = poifs.createDocumentInputStream("Workbook");
        // construct out HSSFRequest object
        HSSFRequest req = new HSSFRequest();
        // lazy listen for ALL records with the listener shown above
        req.addListenerForAllRecords(new EventExample());
        // create our event factory
        HSSFEventFactory factory = new HSSFEventFactory();
        // process our events based on the document input stream
        factory.processEvents(req, din);
        // once all the events are processed close our file input stream
        fin.close();
        // and our document input stream (don't want to leak these!)
        din.close();
        System.out.println("done.");
    }
}

END:
Comment 1 Kjeld Poulsen 2003-02-28 14:08:28 UTC
The problem seems to disapear in the 1.11 version. However this is a dev
and not a RELEASE. Is there any plan for an upcomming RELEASE version.
Comment 2 Avik Sengupta 2003-02-28 14:24:13 UTC
Formula's were disabled in 1.5, since they were not complete then. Many people
find the dev releases stable enuf for their work. If it passes *your* unit
tests, go for it. 
Comment 3 Andy Oliver 2003-03-03 14:17:24 UTC
April of last year.