打印值问题 [英] Printing values problem

查看:66
本文介绍了打印值问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

在csv文件中,有一个字符串值(日期),显示为:00:55.0,但是单击该字符串时,在编辑栏中显示21:00:55.

当我尝试提取值时,代码:

Hi All,

In csv file, there is a string value(date)that appears as: 00:55.0 , but when clicked on that, 21:00:55 appears in the formula bar.

When I try to extract the value, the code :

wchar_t *pStrTime    =  str3; // this variable holds the time value  



当我在调试中运行程序以检查值时,此pStrTime需要21:00:55,但是当我使用:
打印时



When I run my program in debug, to check the values, this pStrTime takes 21:00:55, but when I print this using :

wchar_t *pStrTime    =  str3; // this variable holds the time value  str.Format(_T("%s),pstrTime)



但是当我打印时,将打印00:55.0.

为什么?



But when I print it, 00:55.0 is printed.

Why is that?

推荐答案

如果您正在使用swscanf_s函数进行阅读,我会猜测它确实不是Excel文件-也许是一个csv文件(默认情况下会在Excel中打开).

至于Excel中显示00:55.0且显示为21:00:55的显示,则需要注意Excel试图在读取数据时变得聪明".也就是说,它尝试以Excel认为应该的方式格式化数据-这并不总是正确的.

如果单击该单元格并使用自定义格式对其进行格式化,则会看到不同的显示.例如,该特定数据似乎是日期/时间,但也可能包含毫秒,因此将自定义格式设置为"hh:mm:ss.000"(不带引号),您将看到类似21的内容:55:00.000在Excel中.

希望这会有所帮助.
If you''re reading it with swscanf_s function, I''m going to guess that it really isn''t an Excel file - perhaps a csv file (that will open in Excel by default).

As for the display in Excel showing 00:55.0 and the value appearing to be 21:00:55, you need to be aware that Excel attempts to be "smart" about reading your data. That is to say it attempts to format the data in a way that Excel thinks it should be - which is not always right.

If you click on that cell and format it with a custom format you will see different displays. For instance, that particular data appears to be a date/time, but also perhaps with milliseconds included, so set the custom format to "hh:mm:ss.000" (without the quotes) and you''ll see something like 21:55:00.000 in Excel.

Hope this helps.


这篇关于打印值问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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