如何用前导零写入csv?
我希望将一些数据写入 CSV 文件.我输入信息的一列是带前导零的整数形式,例如:0000000013.
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.
由于某种原因,excel 将其转换"为 13,我必须使用 10 位数字 (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);
谢谢!!!
推荐答案
在行首添加单引号 '
.这会通知 Excel 不要将该值视为数字.
Add a single quote, '
, at the start of the line. This informs Excel to not treat the value as a number.
相关文章