Hi Marc, Andy; I may have a solution to the problem. If I understand correctly, you'd like to get the value of a cell as a String and have the string formatted appropriately based on the cell's data-format-string. I've written a class I call HSSFDataFormatter (not sure that is the most appropriate name, but anyway...). HSSFDataFormatter returns a formatted string for numeric type cells. For non-numeric cells, it returns String.valueOf(cellValue).
HSSFDataFormatter formatter = new HSSFDataFormatter(); HSSFCell cell = row.getCell(0); String formattedStr = formatter.formatCellValue(cell); The code above returns a formatted string based on the cell's type and data format string: Numeric cell: formattedStr = "$100.00" or "25%" or "Oct 21, 2009 1:30 PM" etc... String cell: formattedStr = cell.getRichStringCellValue().toString(); Boolean cell: formattedStr = String.valueOf(cell.getBooleanCellValue()); Formula cell: formattedStr = cell.getCellFormula(); Blank cell: formattedStr = "" You can also pass in a FormulaEvaluator so that formula cells will be evaluated and then formatted: String formattedStr = formatter.formatCellValue(cell, evaluator); I submitted a patch (https://issues.apache.org/bugzilla/show_bug.cgi?id=45404) for this. You can check out the code in the attachment on bugzilla. If you think this would be beneficial in the API, you can vote for this bug. Thanx James James May Sr. Software Engineer (EPS) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
