From: Yegor Kozlov Date: Sat, 18 Jun 2011 08:39:03 +0000 (+0000) Subject: improved autosizing columns in SXSSF, see Bug 51356 X-Git-Tag: REL_3_8_BETA4~379 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6a46a179d38f0619abee80ad78574e40c67e8be7;p=poi.git 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 --- diff --git a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java index e5e27cdfe1..a7e7d1ce2c 100644 --- a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java +++ b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java @@ -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)); } }