Return-Path: X-Original-To: apmail-poi-commits-archive@minotaur.apache.org Delivered-To: apmail-poi-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C19716510 for ; Mon, 20 Jun 2011 15:17:08 +0000 (UTC) Received: (qmail 42853 invoked by uid 500); 20 Jun 2011 15:17:08 -0000 Delivered-To: apmail-poi-commits-archive@poi.apache.org Received: (qmail 42816 invoked by uid 500); 20 Jun 2011 15:17:08 -0000 Mailing-List: contact commits-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@poi.apache.org Delivered-To: mailing list commits@poi.apache.org Received: (qmail 42809 invoked by uid 99); 20 Jun 2011 15:17:08 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Jun 2011 15:17:08 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Jun 2011 15:17:07 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id C6DDE2388994; Mon, 20 Jun 2011 15:16:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r1137656 - in /poi/trunk/src: documentation/content/xdocs/status.xml java/org/apache/poi/hssf/usermodel/HSSFSheet.java java/org/apache/poi/ss/usermodel/Sheet.java ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java Date: Mon, 20 Jun 2011 15:16:46 -0000 To: commits@poi.apache.org From: yegor@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110620151646.C6DDE2388994@eris.apache.org> Author: yegor Date: Mon Jun 20 15:16:46 2011 New Revision: 1137656 URL: http://svn.apache.org/viewvc?rev=1137656&view=rev Log: Bug 48408: Improved documentation for Sheet.setColumnWidth Modified: poi/trunk/src/documentation/content/xdocs/status.xml poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java poi/trunk/src/java/org/apache/poi/ss/usermodel/Sheet.java poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java Modified: poi/trunk/src/documentation/content/xdocs/status.xml URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=1137656&r1=1137655&r2=1137656&view=diff ============================================================================== --- poi/trunk/src/documentation/content/xdocs/status.xml (original) +++ poi/trunk/src/documentation/content/xdocs/status.xml Mon Jun 20 15:16:46 2011 @@ -34,6 +34,7 @@ + 48408 - Improved documentation for Sheet.setColumnWidth 51390 - Added handling of additional properties to HWPF ParagraphSprmCompressor 51389 - Support for sprmPJc paragraph SPRM in HWPF 48469 - New Case Study for PI web site Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java?rev=1137656&r1=1137655&r2=1137656&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java Mon Jun 20 15:16:46 2011 @@ -429,15 +429,47 @@ public final class HSSFSheet implements /** * Set the width (in units of 1/256th of a character width) + * *

* The maximum column width for an individual cell is 255 characters. * This value represents the number of characters that can be displayed - * in a cell that is formatted with the standard font. + * in a cell that is formatted with the standard font (first font in the workbook). + *

+ * + *

+ * Character width is defined as the maximum digit width + * of the numbers 0, 1, 2, … 9 as rendered + * using the default font (first font in the workbook). + *
+ * Unless you are using a very special font, the default character is '0' (zero), + * this is true for Arial (default font font in HSSF) and Calibri (default font in XSSF) + *

+ * + *

+ * Please note, that the width set by this method includes 4 pixels of margin padding (two on each side), + * plus 1 pixel padding for the gridlines (Section 3.3.1.12 of the OOXML spec). + * This results is a slightly less value of visible characters than passed to this method (approx. 1/2 of a character). *

+ *

+ * To compute the actual number of visible characters, + * Excel uses the following formula (Section 3.3.1.12 of the OOXML spec): + *

+ * + * width = Truncate([{Number of Visible Characters} * + * {Maximum Digit Width} + {5 pixel padding}]/{Maximum Digit Width}*256)/256 + * + *

Using the Calibri font as an example, the maximum digit width of 11 point font size is 7 pixels (at 96 dpi). + * If you set a column width to be eight characters wide, e.g. setColumnWidth(columnIndex, 8*256), + * then the actual value of visible characters (the value shown in Excel) is derived from the following equation: + * + Truncate([numChars*7+5]/7*256)/256 = 8; + * + * + * which gives 7.29. * * @param columnIndex - the column to set (0-based) * @param width - the width in units of 1/256th of a character width - * @throws IllegalArgumentException if width > 65280 (the maximum column width in Excel) + * @throws IllegalArgumentException if width > 255*256 (the maximum column width in Excel is 255 characters) */ public void setColumnWidth(int columnIndex, int width) { _sheet.setColumnWidth(columnIndex, width); Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/Sheet.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/Sheet.java?rev=1137656&r1=1137655&r2=1137656&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/ss/usermodel/Sheet.java (original) +++ poi/trunk/src/java/org/apache/poi/ss/usermodel/Sheet.java Mon Jun 20 15:16:46 2011 @@ -118,19 +118,59 @@ public interface Sheet extends Iterable< /** * Set the width (in units of 1/256th of a character width) + * *

* The maximum column width for an individual cell is 255 characters. * This value represents the number of characters that can be displayed - * in a cell that is formatted with the standard font. + * in a cell that is formatted with the standard font (first font in the workbook). + *

+ * + *

+ * Character width is defined as the maximum digit width + * of the numbers 0, 1, 2, … 9 as rendered + * using the default font (first font in the workbook). + *
+ * Unless you are using a very special font, the default character is '0' (zero), + * this is true for Arial (default font font in HSSF) and Calibri (default font in XSSF) + *

+ * + *

+ * Please note, that the width set by this method includes 4 pixels of margin padding (two on each side), + * plus 1 pixel padding for the gridlines (Section 3.3.1.12 of the OOXML spec). + * This results is a slightly less value of visible characters than passed to this method (approx. 1/2 of a character). *

+ *

+ * To compute the actual number of visible characters, + * Excel uses the following formula (Section 3.3.1.12 of the OOXML spec): + *

+ * + * width = Truncate([{Number of Visible Characters} * + * {Maximum Digit Width} + {5 pixel padding}]/{Maximum Digit Width}*256)/256 + * + *

Using the Calibri font as an example, the maximum digit width of 11 point font size is 7 pixels (at 96 dpi). + * If you set a column width to be eight characters wide, e.g. setColumnWidth(columnIndex, 8*256), + * then the actual value of visible characters (the value shown in Excel) is derived from the following equation: + * + Truncate([numChars*7+5]/7*256)/256 = 8; + * + * + * which gives 7.29. * * @param columnIndex - the column to set (0-based) * @param width - the width in units of 1/256th of a character width + * @throws IllegalArgumentException if width > 255*256 (the maximum column width in Excel is 255 characters) */ void setColumnWidth(int columnIndex, int width); /** * get the width (in units of 1/256th of a character width ) + * + *

+ * Character width is defined as the maximum digit width + * of the numbers 0, 1, 2, … 9 as rendered + * using the default font (first font in the workbook) + *

+ * * @param columnIndex - the column to set (0-based) * @return width - the width in units of 1/256th of a character width */ Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java?rev=1137656&r1=1137655&r2=1137656&view=diff ============================================================================== --- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (original) +++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java Mon Jun 20 15:16:46 2011 @@ -1899,15 +1899,47 @@ public class XSSFSheet extends POIXMLDoc /** * Set the width (in units of 1/256th of a character width) + * *

* The maximum column width for an individual cell is 255 characters. * This value represents the number of characters that can be displayed - * in a cell that is formatted with the standard font. + * in a cell that is formatted with the standard font (first font in the workbook). + *

+ * + *

+ * Character width is defined as the maximum digit width + * of the numbers 0, 1, 2, … 9 as rendered + * using the default font (first font in the workbook). + *
+ * Unless you are using a very special font, the default character is '0' (zero), + * this is true for Arial (default font font in HSSF) and Calibri (default font in XSSF) + *

+ * + *

+ * Please note, that the width set by this method includes 4 pixels of margin padding (two on each side), + * plus 1 pixel padding for the gridlines (Section 3.3.1.12 of the OOXML spec). + * This results is a slightly less value of visible characters than passed to this method (approx. 1/2 of a character). *

+ *

+ * To compute the actual number of visible characters, + * Excel uses the following formula (Section 3.3.1.12 of the OOXML spec): + *

+ * + * width = Truncate([{Number of Visible Characters} * + * {Maximum Digit Width} + {5 pixel padding}]/{Maximum Digit Width}*256)/256 + * + *

Using the Calibri font as an example, the maximum digit width of 11 point font size is 7 pixels (at 96 dpi). + * If you set a column width to be eight characters wide, e.g. setColumnWidth(columnIndex, 8*256), + * then the actual value of visible characters (the value shown in Excel) is derived from the following equation: + * + Truncate([numChars*7+5]/7*256)/256 = 8; + * + * + * which gives 7.29. * * @param columnIndex - the column to set (0-based) * @param width - the width in units of 1/256th of a character width - * @throws IllegalArgumentException if width > 65280 (the maximum column width in Excel) + * @throws IllegalArgumentException if width > 255*256 (the maximum column width in Excel is 255 characters) */ public void setColumnWidth(int columnIndex, int width) { if(width > 255*256) throw new IllegalArgumentException("The maximum column width for an individual cell is 255 characters."); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org For additional commands, e-mail: commits-help@poi.apache.org