如何写入带有前导零的csv? [英] how to write to csv with a leading zero?
本文介绍了如何写入带有前导零的csv?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
出于某种原因,excel将它转换为13 ,我必须有10位数字(0000000013)。任何人都可以告诉这可以绕过吗?
字符串值=0000000013; //我试过String.format(%8d,13)不起作用
printWriter.println(value);
谢谢!!!
解决方案
在行首添加一个单引号,'
。这通知Excel不会将该值视为数字。
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!!!
解决方案
Add a single quote, '
, at the start of the line. This informs Excel to not treat the value as a number.
这篇关于如何写入带有前导零的csv?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文