From 86513f0dbea1bdbe09f751243199b3a2a25654a5 Mon Sep 17 00:00:00 2001 From: Yegor Kozlov Date: Mon, 18 Aug 2008 18:33:58 +0000 Subject: [PATCH] fixed bug #45645: Fix for HSSFSheet.autoSizeColumn() for widths exceeding Short.MAX_VALUE git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@686844 13f79535-47bb-0310-9956-ffa450edef68 --- src/documentation/content/xdocs/changes.xml | 1 + src/documentation/content/xdocs/status.xml | 1 + src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/documentation/content/xdocs/changes.xml b/src/documentation/content/xdocs/changes.xml index e313d8ced..e23cb3169 100644 --- a/src/documentation/content/xdocs/changes.xml +++ b/src/documentation/content/xdocs/changes.xml @@ -37,6 +37,7 @@ + 45645 - Fix for HSSFSheet.autoSizeColumn() for widths exceeding Short.MAX_VALUE 45623 - Support for additional HSSF header and footer fields, including bold and full file path 45623 - Support stripping HSSF header and footer fields (eg page number) out of header and footer text if required 45622 - Support stripping HWPF fields (eg macros) out of text, via Range.stripFields(text) diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index f0352ea5f..33c86d589 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 45645 - Fix for HSSFSheet.autoSizeColumn() for widths exceeding Short.MAX_VALUE 45623 - Support for additional HSSF header and footer fields, including bold and full file path 45623 - Support stripping HSSF header and footer fields (eg page number) out of header and footer text if required 45622 - Support stripping HWPF fields (eg macros) out of text, via Range.stripFields(text) diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java index 84a71a89a..ef3d58006 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java @@ -1787,10 +1787,11 @@ public final class HSSFSheet { } if (width != -1) { + width *= 256; if (width > Short.MAX_VALUE) { //width can be bigger that Short.MAX_VALUE! width = Short.MAX_VALUE; } - sheet.setColumnWidth(column, (short) (width * 256)); + sheet.setColumnWidth(column, (short) (width)); } }