From 434ce09afdb94ad59a93ab70f55fe18c96e88cf4 Mon Sep 17 00:00:00 2001 From: Yegor Kozlov Date: Wed, 2 Apr 2008 10:25:18 +0000 Subject: [PATCH] Fixed inconsistency between HSSFSHeet.getColumnWidth and HSSFSheet.getDefaultColumnWidth: getColumnWidth should always return width measured in 1/256th units. git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@643834 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/poi/hssf/model/Sheet.java | 12 ++-- .../org/apache/poi/hssf/data/colwidth.xls | Bin 0 -> 13824 bytes .../poi/hssf/usermodel/TestHSSFSheet.java | 62 +++++++++++++++++- 3 files changed, 68 insertions(+), 6 deletions(-) create mode 100755 src/testcases/org/apache/poi/hssf/data/colwidth.xls diff --git a/src/java/org/apache/poi/hssf/model/Sheet.java b/src/java/org/apache/poi/hssf/model/Sheet.java index 451cde7579..2af25e7481 100644 --- a/src/java/org/apache/poi/hssf/model/Sheet.java +++ b/src/java/org/apache/poi/hssf/model/Sheet.java @@ -1879,12 +1879,12 @@ public class Sheet implements Model } /** - * get the width of a given column in units of 1/20th of a point width (twips?) + * get the width of a given column in units of 1/256th of a character width * @param column index * @see org.apache.poi.hssf.record.DefaultColWidthRecord * @see org.apache.poi.hssf.record.ColumnInfoRecord * @see #setColumnWidth(short,short) - * @return column width in units of 1/20th of a point (twips?) + * @return column width in units of 1/256th of a character width */ public short getColumnWidth(short column) @@ -1912,7 +1912,9 @@ public class Sheet implements Model } else { - retval = defaultcolwidth.getColWidth(); + //default column width is measured in characters + //multiply + retval = (short)(256*defaultcolwidth.getColWidth()); } return retval; } @@ -1951,9 +1953,9 @@ public class Sheet implements Model } /** - * set the width for a given column in 1/20th of a character width units + * set the width for a given column in 1/256th of a character width units * @param column - the column number - * @param width (in units of 1/20th of a character width) + * @param width (in units of 1/256th of a character width) */ public void setColumnWidth(short column, short width) { diff --git a/src/testcases/org/apache/poi/hssf/data/colwidth.xls b/src/testcases/org/apache/poi/hssf/data/colw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