2001 JI Open Discussion Posted August 21, 2006 Share Posted August 21, 2006 By: Steve Jenkings - stevejenks Excel IS_AUTO_DETECT_CELL_TYPE Suggestion 2005-11-02 10:01I wonder what the Jasper authors think about changing the code in the JRXlsExporter class 'exportText' method as follows.. Current code. if (isAutoDetectCellType) { try { cell.setCellValue(Double.parseDouble(styledText.getText())); } catch(NumberFormatException e) { cell.setCellValue(JRStringUtil.replaceDosEOL(styledText.getText())); } } Proposed code. if (isAutoDetectCellType) { try { cell.setCellValue(Double.parseDouble(styledText.getText().replaceAll(",", ""))); } catch(NumberFormatException e) { cell.setCellValue(JRStringUtil.replaceDosEOL(styledText.getText())); } } i.e. by stripping out any commas in the text string before attempting to convert the String to a Double we can successfully convert Strings such as "123,456.00" into numbers. Best, Steve. By: Doug Berkland - berkland RE: Excel IS_AUTO_DETECT_CELL_TYPE Suggestion 2005-11-03 02:16It would need to be more complex than that so as not to break the locales that use comma as the decimal point and period as the thousands seperator. Link to comment Share on other sites More sharing options...
kriegerd Posted March 6, 2007 Share Posted March 6, 2007 It can't be done that way as Doug said. There should be a number formatter formatter somewhere that could parse the number properly 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