Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

How to display exponents to a number in excel

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I am writing some data into an excel file using Struts2. The policy number is of type String and when I download the csv file and open it in excel the policy number comes as exponent. It is a large number therefore excel displays it this way but is there any way in Java side to take care of such thing.

I want this 4.01021E+13 to be 40102100156108

Can I convert this String to show up as a number rather than exponent in Java.
Thanks.



 
Bartender
Posts: 9612
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you formatting the field as a String in your CSV (i.e. enclosing the value in double-quotes)?  
Comma-separated values
 
syed yousuf sadat
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In CSV, I am not doing anything. I just get the values through getters and write them in CSV. This field is of type String and it is almost 15 digit number.
 
syed yousuf sadat
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I added a single quote just before the getter and appending it to it. It displays the complete number but it also prints the quote which I don't want.

This is how it showed up: '0412365987456321
This is how I want it:        0412365987456321
 
His brain is the size of a cherry pit! About the size of this ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic