Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to write to csv with a leading zero?

I wish to write to a CSV file some data. One of the column that I input the information is in the form of an integer with leading zeros, example: 0000000013.

For some reason, excel 'converts' it to 13, and I must have it with 10 digits (0000000013). Can anyone tell how this can be circumvented?

String value = "0000000013"; //I tried String.format("%8d", 13) doesn't work
printWriter.println(value);

Thanks!!!

like image 763
adhg Avatar asked Dec 06 '25 06:12

adhg


1 Answers

Append tab to the number

ex: "\t"+"01234"

like image 160
madhavi Avatar answered Dec 08 '25 21:12

madhavi