yaramada123 Posted July 23, 2007 Share Posted July 23, 2007 Hi,I am trying to export a 16 digit number into XLS, but it is getting exported as exponential number. 1. I used JXL api to open the sheet and edit the number so that it is displayed as normal number. 2. The problem I am facing is, If I am exporting 5000323421232345, the last digit is getting replaced with 0 instead of 5 as it is getting converted to exponential number 5.0000E+15 when Jasper exports it into XLS. How do I get around this problem, I can turn of IS_AUTO_CELL_DETECT_TYPE as there are numbers in other columns. Please let me know if any one knows a solution for this. Link to comment Share on other sites More sharing options...
arunvishvin Posted July 24, 2007 Share Posted July 24, 2007 Hi,I also faced the same problem what i did was, We used to print 16 digit numbers as TxnNo:1234567890123456 and I added the ":" into the report before the field value like this":"+$F{Field Name} and that solved the problem.You also try to add some character but not space before your field value, it will surely work Link to comment Share on other sites More sharing options...
lucianc Posted July 24, 2007 Share Posted July 24, 2007 According to Microsoft KB, the numerical precision in Excel 2000 is 15 digits. Therefore you will never be able to include a 16 digit number in a worksheet without losing the last digit. If you want to include the number as text, you should set the JRXlsAbstractExporterParameter.IS_DETECT_CELL_TYPE export flag (which would deactivate IS_AUTO_DETECT_CELL_TYPE) and make sure your text has java.lang.String as type. While IS_AUTO_DETECT_CELL_TYPE guesses the cell type based on the cell text, IS_DETECT_CELL_TYPE uses the type of the text field expression to determine the cell type. Note, therefore, that if you have a java.lang.String text field which was interpreted by IS_AUTO_DETECT_CELL_TYPE as a number, this would not happen with IS_DETECT_CELL_TYPE. HTH,Lucian Link to comment Share on other sites More sharing options...
szaharia Posted July 24, 2007 Share Posted July 24, 2007 If you want to avoid both exponential conversion and text representation of your big number, there is another possibility: try to use the java.math.BigDecimal (or BigInteger - your number appears to be rather integer) type instead of Double. But, of course, try that only if your precision does fit into Excel's allowed limits, as Lucian said. Post edited by: shertage, at: 2007/07/24 09:04 Link to comment Share on other sites More sharing options...
yaramada123 Posted July 27, 2007 Author Share Posted July 27, 2007 Thank you very much for the replies!!! using IS_DETECT_CELL_TYPE solved my issue, I was using IS_AUTO_DETECT_CELL_TYPE earlier which was messing up my excel output. 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