开发者

Opening HTML Table in Excel - numbers are getting changed

开发者 https://www.devze.com 2022-12-26 01:41 出处:网络
so I have this HTML table with a bunch of big numbers in it that I want to open in Excel 2007... you can follow along at home:

so I have this HTML table with a bunch of big numbers in it that I want to open in Excel 2007... you can follow along at home:

<table>
<tr>
    <td>this is a big number</td>
</tr><开发者_如何学C;tr>
    <td>1111111</td>
</tr><tr>
    <td>2335322864</td>
</tr><tr>
    <td>23353228641</td>
</tr><tr>
    <td>233532286418</td>
</tr><tr>
    <td>2335322864187</td>
</tr><tr>
    <td>23353228641877</td>
</tr><tr>
    <td>233532286418777</td>
</tr><tr>
    <td>2335322864187774</td>
</tr><tr>
    <td>23353228641877745</td>
</tr><tr>
    <td>233532286418777456</td>
</tr><tr>
    <td>2335322864187774562</td>
</tr><tr>
    <td>23353228641877745623</td>
</tr><tr>
    <td>233532286418777456238</td>
</tr>

when I open this file in Excel it starts converting those numbers to scientific notation when they get over 10 digits in length... and in doing so, it starts changing the actual number and replaces least significant digits to zeros

how can I tell Excel not to do this?


Make them strings, for example by putting quotes around them (or in front). Not exactly ideal, but you can later replace all the quotes with nothing.


In Excel 2007, it opened fine. I simply had to change the NumberFormat to 0000000000000000000000.

In general, trying to get Excel to interpret an Html file is fragile. You should instead use Spreadsheet XML or create an actual Excel binary using something like NPOI. There is a means in both Spreadsheet XML and NPOI to declare the number format.

ADDITION It should also be noted that you are reaching the upper limits of Excel's numeric values. From their documentation, the highest numeric precision is 15 digits. That means anything bigger than that must be converted to scientific notation if it is to be used in calculations.

See Calculation specifications and limits for more.

0

精彩评论

暂无评论...
验证码 换一张
取 消