Microsoft Excel will automatically convert data columns into the format that it thinks is best when opening comma-separated data files. For those of us that don’t want our data changed, we can change that behavior.

Microsoft Excel将在打开以逗号分隔的数据文件时自动将数据列转换为它认为最佳的格式。 对于那些不想更改数据的人,我们可以更改其行为。

You have a CSV file probably exported from other application or given to you by other people. You would like to open it up in Excel since you know it very well. The CSV file will look like this (if you open the file in notepad.exe):

您有一个CSV文件,它可能是从其他应用程序导出或由其他人提供给您的。 您很想在Excel中打开它。 CSV文件将如下所示(如果您在notepad.exe中打开文件):

The file contains columns: ProductModelID, Name, SpecialID, and ModifiedDate. The column SpeicalID containing data with leading 0 and it is specialized code so you would like to keep the leading 0s in Excel. Since it is a CSV file it is, by default, shown in your Windows Explorer as an Excel file:

该文件包含以下列:ProductModelID,Name,SpecialID和ModifiedDate。 SpeicalID列包含前导0的数据,它是专用代码,因此您希望在Excel中保留前导0。 由于它是CSV文件,因此默认情况下在Windows资源管理器中将其显示为Excel文件:

So you double-click the file and open the file in Excel as such:


You can see that by default, Excel stripped out the leading 0s in column 3 “SpecialID

您可以看到,默认情况下,Excel在第3列“ SpecialID”中去除了前导0

翻译自: https://www.howtogeek.com/howto/microsoft-office/how-to-import-a-csv-file-containing-a-column-with-a-leading-0-into-excel/