ktrinad Posted August 20, 2006 Share Posted August 20, 2006 By: josep - josepse Locale not considered when exporting to Excel 2004-05-13 00:48Hi, When exporting a number to Excel the code expects the "." as a decimal separator and doesn't treat de grouping separator. My locale has "," as decimal separator and "." as grouping separator. Here is a possible modification to update this bug: protected void exportText(JRPrintText text, JRExporterGridCell gridCell, int x, int y) { .... if (isAutoDetectCellType) { try { java.text.DecimalFormat dec = new java.text.DecimalFormat(); java.text.ParsePosition pos = new java.text.ParsePosition(0); Number num = dec.parse(text.getText().trim(), pos); if (pos.getIndex() != text.getText().trim().length()) cell.setCellValue(text.getText()); else cell.setCellValue(num.doubleValue()); } catch(Exception e) { cell.setCellValue(text.getText()); } } ... } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now