2

I'm trying to use POI to read an Excel file. It will be a large file ( > 50k rows) so I'm using the eventusermodel rather than the simpler usermodel which reads the entire file into memory. My code looks like:

    File file = new File("C:\\bigfile.xls");
    InputStream input = new FileInputStream(file);
    EventRecordFactory factory = new EventRecordFactory(new ERFListener() {
        @Override
        public boolean processRecord(Record rec)
        {
            return true;
        }
    }, RecordFactory.getAllKnownRecordSIDs());
    factory.processRecords(input);

But I get the exception

org.apache.poi.hssf.record.RecordFormatException: The content of an excel record cannot exceed 8224 bytes

This exception was supposedly fixed in 3.5, however, I'm using 3.6 and I also tried the latest trunk pull from POI and still the same issue.

I've tried shrinking the file to just have a few rows but the same error. Has anyone dealt with this before?

thanks, Jeff

1
  • You ever get an answer on this? I'm having the same trouble and I can't seem to find an answer any where. Commented Jul 29, 2010 at 17:28

2 Answers 2

1

You should use EventRecordFactory.processRecords method with DocumentInputStream type as it's parameter. (instead of pure FileInputStream).

POIFSFileSystem poifs = new POIFSFileSystem(input);
DocumentInputStream documentInputStream = poifs.createDocumentInputStream("Workbook");
factory.processRecords(documentInputStream);
Sign up to request clarification or add additional context in comments.

Comments

0

Do you have any large comments in the excel file. If so could you try after removing the comments.

1 Comment

I removed everything except two rows "a b c" and "d e f" but still getting the error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.