From: Yegor Kozlov Date: Sun, 13 Sep 2009 17:49:46 +0000 (+0000) Subject: fixed XSSFSheet.setColumnWidth to produce XML compatible with Mac Excel 2008, see... X-Git-Tag: REL_3_5-FINAL~8 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a90c8202db19b858a2c3b5c1d0fcc83428e99afa;p=poi.git fixed XSSFSheet.setColumnWidth to produce XML compatible with Mac Excel 2008, see Bugzilla 47581 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@814358 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 108984d635..17ada799c7 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -33,6 +33,7 @@ + 47581 - fixed XSSFSheet.setColumnWidth to produce XML compatible with Mac Excel 2008 47734 - removed unnecessary svn:executable flag from files in SVN trunk 47543 - added javadoc how to avoid Excel crash when creating too many HSSFRichTextString cells 47813 - fixed problems with XSSFWorkbook.removeSheetAt when workbook contains chart diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java index 935774582c..4fb9185b90 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java @@ -1675,6 +1675,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { if(width > 255*256) throw new IllegalArgumentException("The maximum column width for an individual cell is 255 characters."); columnHelper.setColWidth(columnIndex, (double)width/256); + columnHelper.setCustomWidth(columnIndex, true); } public void setDefaultColumnStyle(int column, CellStyle style) { diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java index 7bcf9c1cb4..39a1a4d766 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java @@ -695,6 +695,7 @@ public class TestXSSFSheet extends BaseTestSheet { assertEquals(2, col.getMin()); assertEquals(2, col.getMax()); assertEquals(22.0, col.getWidth(), 0.0); + assertTrue(col.getCustomWidth()); // Now set another sheet.setColumnWidth(3, 33 * 256); @@ -708,10 +709,12 @@ public class TestXSSFSheet extends BaseTestSheet { assertEquals(2, col.getMin()); // POI 1 assertEquals(2, col.getMax()); assertEquals(22.0, col.getWidth(), 0.0); + assertTrue(col.getCustomWidth()); col = cols.getColArray(1); assertEquals(4, col.getMin()); // POI 3 assertEquals(4, col.getMax()); assertEquals(33.0, col.getWidth(), 0.0); + assertTrue(col.getCustomWidth()); } }