如何用前导零写入csv? [英] how to write to csv with a leading zero?

查看:31
本文介绍了如何用前导零写入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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆