在 Excel 中以原始字符串形式查看 CSV 文件日期

发布于 2025-01-11 08:42:44 字数 433 浏览 4 评论 0原文

我有一个 CSV 文件,其中包含时间列,其值是 dd MMM HH:mm 格式的字符串。

Name,Time
Farms,20 Dec 14:00

当我使用 Excel 打开 CSV 文件时,Excel 会自动将这些时间值转换为日期格式,从而修改为自行添加年份值。因此 20 Dec 14:00 会转换为 20/12/22 14:00

我想要的是 Excel 应该将时间列值显示为原始字符串,即12 月 20 日 14:00

一些类似的问题,建议修改CSV文件,在时间列值之前添加=符号,以便excel将其视为字符串。但这不是我想要的。 我不想对 CSV 文件进行任何更改,但想要通过在 Excel 本身中进行一些更改来实现。

I have a CSV file which has time column and its values are String in dd MMM HH:mm format.

Name,Time
Farms,20 Dec 14:00

When I open the CSV file with Excel, Excel automatically converts these Timevalues to date format, thereby modifying to add year value on its own. So 20 Dec 14:00 is converted to 20/12/22 14:00.

What I want is that Excel should display the time column values as raw string, i,e. 20 Dec 14:00.

Some similar questions, suggetsed to modify the CSV file by adding = symbol before the time column values, so that excel treat it as string. But this is not what I want.
I don't want to make any changes to CSV file, but want a way by making some changes in Excel itself.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陈甜 2025-01-18 08:42:44

不要通过直接双击或将其拖到 EXCEL 实例上来打开 .CSV 文件,而是尝试使用“文件”->“打开”方法,并使用文本导入向导,选择逗号分隔符,然后选择类型的列,选择文本(您可以选择多个列并选择文本)。

或者,创建一个新的空工作表,将第一列格式设置为文本,在良好的文本编辑器(如 Notepad++)中打开文件,复制整个文本(Ctrl-A、Ctrl-C),按 Alt-tab 复制到 EXCEL,将光标置于在 A1 中,然后粘贴 (Ctrl-V)。现在您可以使用“数据”->“文本到列”向导,并且您可以再次选择文本作为类型。

也可以在VBA中完成,但是执行上述步骤是可以接受的,为什么呢?

Instead of opening the .CSV file by directly double-clicking, or dragging it onto an EXCEL instance, try using File->Open method, and use the text import Wizard, choose the comma delimiter, and when when it asks for the type of the column, choose text (you can choose multiple columns and choose text).

Alternatively, create a new empty worksheet, format the first column as text, open the file in a good text editor (like Notepad++), copy whole text (Ctrl-A, Ctrl-C), Alt-tab to EXCEL, place the cursor in A1, and paste (Ctrl-V). Now you can use the Data->Text to Columns wizard, and again you can choose text as type.

It can also be done in VBA, but performing the above steps are acceptable then why.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文