saving csv from excel loses decimal point precision

冷暖自知 提交于 2020-01-02 05:59:12

问题


If I create a simple .csv file containing something like this:

01/22/2013,3.14159265358979323846264338

and proceed to open it up in excel, the cell will show a rounded number i.e. 3.141592654 and the formula bar will show the whole value. However if I make some changes and save the csv file, or just save the original file as a different csv file, the file will only contain the rounded number 3.141592654, causing me to lose some decimal point precision.

I am writing these files out via a vba macro. I have tried :

ActiveWindow.DisplayFormulas=True

before the save command, and it works except it changes my date into a numeric format and I have not figured out a way to apply this format to only a range of cells. Is there some simple way to keep my numeric precision?


回答1:


If you know which cells are going to be affected, try something like

Range("MYNUMBERS").NumberFormat = "#0.000000000000000"

?



来源:https://stackoverflow.com/questions/14462548/saving-csv-from-excel-loses-decimal-point-precision

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!