aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYegor Kozlov <yegor@apache.org>2011-06-18 08:39:03 +0000
committerYegor Kozlov <yegor@apache.org>2011-06-18 08:39:03 +0000
commit6a46a179d38f0619abee80ad78574e40c67e8be7 (patch)
treeaa3c912da75b0a2c1a34f9606c613cec646cf25a
parente40d99937e2acd9a2e4a1f759b9522e9919f8fc2 (diff)
downloadpoi-6a46a179d38f0619abee80ad78574e40c67e8be7.tar.gz
poi-6a46a179d38f0619abee80ad78574e40c67e8be7.zip
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
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java10
1 files changed, 8 insertions, 2 deletions
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));
}
}