导出到 csv/excel 方式以包含前导零 [英] Export to csv/excel way to include leading zero

查看:51
本文介绍了导出到 csv/excel 方式以包含前导零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将选择查询数据从 mysql 导出到 csv &用excel打开,前导零不见了.

Exporting select query data from mysql to csv & opening with excel, the leading zeros are gone.

虽然列是varchar,但是当数据导出时,它写成

Although the column is varchar, when the data gets exported, it writes like

4567 而不是 04567, 有没有办法在导出到 csv 时保留前导零?

4567 instead of 04567, is there a way to preserve the leading zero while exporting to csv?

推荐答案

您需要将数字括在双引号中,例如:...,"04567",...,但随后它将被解释为电子表格中的文本,因此除非您先进行转换(整数不能以 0 在 excel 中开头),否则整数运算将无法对其进行处理.

You need to wrap the number in double quotes like: ...,"04567",..., but then it will be interpreted as text in the spreadsheet so integer arithmetic will not work on it unless you do a conversion first (integers cannot begin with 0 in excel).

这篇关于导出到 csv/excel 方式以包含前导零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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