aspose file tools*
The moose likes Java in General and the fly likes Data is not properly export in the csv file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Data is not properly export in the csv file" Watch "Data is not properly export in the csv file" New topic
Author

Data is not properly export in the csv file

sumanta panda
Ranch Hand

Joined: Jun 23, 2008
Posts: 224
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
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

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.


[My Blog]
All roads lead to JavaRanch
sumanta panda
Ranch Hand

Joined: Jun 23, 2008
Posts: 224
I am using Microsoft office excel 2003.

Please suggest how to fix this error.

Thanks,
Sumanta Panda
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
jQuery in Action, 2nd edition
 
subject: Data is not properly export in the csv file