Bug 47751 - don't allow too-large cell values?
Summary: don't allow too-large cell values?
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.5-dev
Hardware: PC Windows Vista
: P2 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2009-08-27 11:19 UTC by Rodney Gitzel
Modified: 2009-09-06 22:02 UTC (History)
0 users

short sample to create XLS with error (776 bytes, application/octet-stream)
2009-08-27 11:19 UTC, Rodney Gitzel

Note You need to log in before you can comment on or make changes to this bug.
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

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.