views:

115

answers:

2

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><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?

+1  A: 

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.

MJB
i don't want to change the data... the client should see the # as it is in the file... not have to deal with quotes
Nick Franceschina
Unfortunately, that is how MS suggest you do it also. Check this out for more info that might help you: http://support.microsoft.com/kb/214233
MJB
well, they suggest putting a quote in the front... which tells Excel that it isn't a number, but a string. unfortunately that only work in the Excel app... not from an HTML file. but there was a good suggestion on that site that I was contemplating anyways... put a space at the front... that would tell Excel "this is a string, not a number" and doesn't put extra data in the cell (like a quote)
Nick Franceschina
accepting this one because it is the path I am ultimately choosing for the short term... in order to force Excel to interpret a large number as a string, I am prefixing them with   in the HTML... which I'm able to do with very little hassle... and that solves this particular problem quite nicely (although ultimately there is a better architecture to be had)
Nick Franceschina
+1  A: 

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.

Thomas
well, that works unless you have a number that is more than the number of zeros you have there. anyways, you're right... i should probably use SpreadsheetML instead
Nick Franceschina
Thanks Thomas, you ultimately have the "correct" solution, but not the one I'm going to use... because it requires a helluva lot more work, which I'm not authorized to do... so I hafta give it to MJB
Nick Franceschina