You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2008/07/16 05:49:22 UTC

DO NOT REPLY [Bug 45404] New: [PATCH] New class to obtain formatted cell values

https://issues.apache.org/bugzilla/show_bug.cgi?id=45404

           Summary: [PATCH] New class to obtain formatted cell values
           Product: POI
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: HSSF
        AssignedTo: dev@poi.apache.org
        ReportedBy: james.may@fmr.com


HSSFDataFormatter contains methods for formatting the value stored in an
HSSFCell. This can be useful for reports and GUI presentations when you need to
display data exactly as it appears in Excel. Supported formats include
currency, SSN, percentages, decimals, dates, phone numbers, zip codes, etc. 


Usage:

HSSFCell cell = row.getCell(0);
HSSFDataFormatter fomatter = new HSSFDataFormatter();
String formattedStr = formatter.formatCellValue(cell);

-This yields a formatted string based on the cell type & format:
-CELL_TYPE_STRING = returns string value as is
-CELL_TYPE_BOOLEAN = returns "true" or "false"
-CELL_TYPE_BLANK = returns ""
-CELL_TYPE_FORMULA = cell formula string
-CELL_TYPE_NUMERIC = formatted value i.e. "$1,000.00 USD", "61.54%", "Thursday,
January 02, 2003"

-There's also an overloaded method that takes a FormulaEvaluator:

String formattedStr = formatter.formatCellValue(cell, evaluator);

-CELL_TYPE_FORMULA = cell formula is evaluated, then formatted
-All other cell types = same as above


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 45404] [PATCH] New class to obtain formatted cell values

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45404


Nick Burch <ni...@torchbox.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




--- Comment #2 from Nick Burch <ni...@torchbox.com>  2008-07-20 10:19:34 PST ---
Thanks for this code. I've applied it to svn

(Had to do a few tweaks to make it play nicely with java 1.4, then some more so
that it could work with the eventusermodel stuff, but most of it is unchanged!)


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 45404] [PATCH] New class to obtain formatted cell values

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45404





--- Comment #1 from James <ja...@fmr.com>  2008-07-15 20:51:19 PST ---
Created an attachment (id=22262)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=22262)
enhancement source code in zip archive


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org