improved autosizing columns in SXSSF, see Bug 51356

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1137138 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yegor Kozlov 2011-06-18 08:39:03 +00:00
parent f9bbd32caf
commit 8a61200434

View File

@ -1069,8 +1069,14 @@ public class SXSSFSheet implements Sheet, Cloneable
public void autoSizeColumn(int column, boolean useMergedCells)
{
double width = SheetUtil.getColumnWidth(this, column, useMergedCells);
if(width != -1){
setColumnWidth(column, (int)(width*256));
if (width != -1) {
width *= 256;
int maxColumnWidth = 255*256; // The maximum column width for an individual cell is 255 characters
if (width > maxColumnWidth) {
width = maxColumnWidth;
}
setColumnWidth(column, (int)(width));
}
}