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
Created attachment 22262 [details] enhancement source code in zip archive
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!)