Win a copy of Head First Android this week in the Android 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Data is not properly export in the csv file

 
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All,

In the below given code i am properly fetching the data from database.The value i am fetching from database i am export the data in the csv file.
The System.out.println prints like
PER_NR LNAME
000329 Cory
0011333 Kline
For PER_NR column data when export in the csv file it removes the 00 value in the left side.But i should export the value like example. 000329
Please suggest how i display 000 value in the csv file.




Thanks and Regards,
Sumanta Panda
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

For PER_NR column data when export in the csv file it removes the 00 value in the left side.


Which editor did you use ? Excel ?
Excel formats the value as a number. Check the content of the file using a text editor.
 
sumanta panda
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using Microsoft office excel 2003.

Please suggest how to fix this error.

Thanks,
Sumanta Panda
 
Sheriff
Posts: 22508
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's not an error in your Java code, nor in your CSV file. It's stupid Excel that thinks "all digits! it must be a number! cool! let's take off the leading zeros!". You may be able to solve this by specifying that the column is Text, not General or Number, but it wouldn't surprise me if this wouldn't work.
 
reply
    Bookmark Topic Watch Topic
  • New Topic