how to write to csv with a leading zero?(如何用前导零写入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.
这篇关于如何用前导零写入csv?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何用前导零写入csv?


- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01