Reputation: 57162
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
Upvotes: 2
Views: 3716
Reputation: 753
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);
Upvotes: 1
Reputation: 3185
Do you have any large comments in the excel file. If so could you try after removing the comments.
Upvotes: 0