Bug 47751

Summary: don't allow too-large cell values?
Product: POI Reporter: Rodney Gitzel <rodney.gitzel>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: enhancement    
Priority: P2    
Version: 3.5-dev   
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   
Attachments: short sample to create XLS with error

Description Rodney Gitzel 2009-08-27 11:19:50 UTC
Created attachment 24181 [details]
short sample to create XLS with error

A 2.6Mb POI-generated XLS file was causing Open Office to crash and Excel 2007
to report errors on opening the file.

I tracked the problem down to one cell that was being filled with 39553
characters, which of course is over Excel's stated limit of 32767 character per
cell.

I've written a wrapper to trap this in our own code, but would it be
appropriate for setCellValue() itself to throw an exception when this happens?

Cheers!  And thanks for the VERY useful library. :-)
Comment 1 Yegor Kozlov 2009-09-06 22:02:48 UTC
A good catch, thanks.

I fixed HSSFCell to throw IllegalArgumentException if the text argument is longer than 32,767 characters, the limit for the XLS format. 

Note, that this is only "write" restriction. POI still can read .xls files with text in cells longer than the limit, for example, created by OpenOffice. 

The fix was applied in r811994.

Yegor