Excel:打开.csv文件时,默认为TEXT,而不是GENERAL [英] Excel: Default to TEXT rather than GENERAL when opening a .csv file

查看:608
本文介绍了Excel:打开.csv文件时,默认为TEXT,而不是GENERAL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以更改打开.csv文件时Excel使用的默认数据类型?我想在读取.csv文件时,Excel对于列数据格式默认为TEXT而不是通用。

Is is possible to change the default data type Excel uses when opening a .csv file? I would like Excel to default to TEXT rather than General for the Column Data Format when reading a .csv file.

我想要能够打开一个.csv文件从我的数据中删除前导0。目前我使用导入外部数据向导读取.csv文件,但我更喜欢能够使用文件/打开或只是双击.csv文件。

I would like to be able to open a .csv without having leading 0's removed from my data. Currently I use the Import External Data wizard when reading a .csv file but I would prefer to be able to use File/Open or to just double click on the .csv file.

推荐答案

一个选项是记录导入过程的宏,这样你可以将TextFileColumnDataTypes定义为Text。
当您记录宏时,您将看到格式设置为 .TextFileColumnDataTypes = Array(2,2,2)

One option is to record a macro of the import process, that way you can define the TextFileColumnDataTypes to be Text. When you record the macro you will see that the format is set with the line .TextFileColumnDataTypes = Array(2, 2, 2)

其中2设置文本格式,数组中的3个元素指向3列。
您可以将数组设置为包含比您希望在文本文件中包含的列数更多的元素,因为任何额外的列都被忽略。

where 2 sets the Text format and the 3 elements in the array refer to 3 columns. You can set the array to contain more elements than the number of columns you expect to have in your text files as any extra are ignored.

F8启动宏对话框,缩短过程,使其类似于从文件菜单打开(虽然仍然不方便,因为能够双击文件)。

You can press F8 to launch the Macro dialog which shortens the process such that it';s similar to opening from the file menu (although still not as convenient as being able to double click a file).

我发现了一个有用的示例宏,其中有一些进一步的说明这里

I found a useful example macro with some further explanations here

这有一点更详细的说明了相关设置的作用,例如在宏中设置正确的分隔符等。

This goes into a bit more detail eexplaining what the relevant settings do, e.g. setting the correct delimiter in the macro etc.

这篇关于Excel:打开.csv文件时,默认为TEXT,而不是GENERAL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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