CSV 文件:Excel 隐藏零
如果我将 csv 文件加载到 Excel 中,值 123.320000 将变为 123.32。
我需要按原样查看所有内容。有什么方法可以阻止Excel隐藏尾随零吗?
阅读其他帖子,我发现这样做可以工作“=”“123.3200000”,但这意味着每次我想查看它时都在文件上运行正则表达式..因为它采用 xxxx|###|xxx 格式并且我无法控制生成部分。
if I load a csv file into excel, value 123.320000 will become 123.32.
i need to view all contents as they are. any way to stop excel from hiding trailing zeros?
reading other posts, i found that doing something like this could work "=""123.3200000" but that would mean running regex on the file every time i want to view it.. since it comes in xxxx|###|xxx format and i have no control over the generation part.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您究竟是如何加载 CSV 文件的?
如果将其导入为“文本”格式,则 Excel 将保留所有格式,包括前导/尾随零。
在 Excel 2010 中,您从“数据”选项卡导入并选择“从文本”,找到 CSV 文件,然后在出现提示时选择将数据格式设置为“文本”
How exactly are you loading the CSV file?
If you import it as "Text" format then Excel will retain all formatting, including leading/trailing zeros.
In Excel 2010 you import from the "Data" tab and choose "From Text", find your CSV file then when prompted choose to format the data as "Text"
我假设一旦导入的值位于工作表中,您希望将它们视为数字而不是文本,即您希望能够求和、相乘等。将值加载为文本将阻止您执行此操作-- 直到您将值转换回数字,在这种情况下您将丢失尾随零,这使您回到最初的难题。
请记住,值 123.32 和 123.3200000 之间没有区别,您想要的只是更改显示格式,以便明确显示值的完整精度。您可以在 VBA 中执行此操作,如下所示:
I'm assuming that once the imported values are in the sheet, you want to treat them as numbers and not as text, i.e. you want to be able to sum, multiply, etc. Loading the values as text will prevent you from doing this -- until you convert the values back to numbers, in which case you will lose the trailing zeros, which brings you back to your initial conundrum.
Keeping in mind that there is no difference between the values 123.32 and 123.3200000, what you want is just to change the display format such that the full precision of your value is shown explicitly. You could do this in VBA like so: