Reputation: 21
In asp.net (vb), I am trying to write the HTML output that I can have a user open up a report in Excel. It's writing my file fine, but when Excel opens the file it is changing the HTML code. The part that it really changes are formulas!
For instance, I am writing out the following (part of the file):
<table>
<tr>
<td>Trial</td><td x:num x:fmla="=SUM(A2:A10)">0</td>
</tr>
</tr></table>
If I open the file in Excel, the cell has a formula of SUM(A13:A21).
Is there something I can do to prevent Excel from changing this when it opens? I want it to have exactly what I write, but it is changing A LOT!
Thanks for any ideas.
Upvotes: 0
Views: 193
Reputation: 21
Tim headed me in the right direction, so thanks.
I'm posting what I found was my idiotic error, just to answer the question. No one is going to do what I did, but here it is.
I was doing a "table" tag for everything when I wrote my program, so my HTML looked like this:
<table><tr>
<tr>
<td x:num>11</td>
<td x:num>12</td>
<td x:num>13</td>
<td x:num>14</td>
</tr></table>
<table> <tr>
<td x:num>21</td>
<td x:num>22</td>
<td x:num>23</td>
<td x:num>24</td>
</tr></table>
<table> <tr>
<td x:num>31</td>
<td x:num>32</td>
<td x:num>33</td>
<td x:num>34</td>
</tr></table>
<tr>
<td>Total Weight</td>
<td></td>
<td x:num x:fmla="=SUM(D4:D10)">0</td>
</tr>
</table>
Obviously, that was changing everything. Changed it to one "table" at the top and "/table" at the end to fix it all.
Thanks for the help!
Ed
Upvotes: 0
Reputation: 166181
This gives me the expected outcome:
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<table>
<tr>
<td>Trial</td><td x:num x:fmla="=SUM($A$2:$A$10)">0</td>
</tr>
</tr>
</table>
</html>
Even without the $ the formula remains as-written: no adjustment. Excel 2013/Win7
Upvotes: 1