I need to achieve the following when opening an HTML in Excel (Response.contentType=\"application/vnd.ms-excel\") :
mso-number-format:0 NO Decimals
mso-number-format:"\#\,\#\#0\.000" 3 Decimals
mso-number-format:"mm\/dd\/yy" Thousand comma with 3 decimals
mso-number-format:"mmmm\\ d\\\,\\ yyyy" Date7
mso-number-format:"m\/d\/yy\\ h\:mm\\ AM\/PM" Date9
Text Column
"<td style=\"mso-number-format:'\@'\">"
or
<td style="mso-number-format:'\@'">
It doesn't works sometimes if you add it using a css class in that case try it using in Style to your TD. I did it for formatting a column to a text. like this
style="mso-number-format:\@;"
For you it would be as
mso-number-format:General
UPDATE: You also need to remove non-breaking spaces (nbsp's) from td cells containing numeric or money information to make formulas work on these cells in Excel. So the problem is solved.
I couldn't get any of the answers on this page to work in Excel 2010. I ended up using this.
<td x:num>123</td>
If you add a CSS Class to your page:
.num {
mso-number-format:General;
}
.date {
mso-number-format:"Short Date";
}
And slap those classes on your TD's, does it work?
<td class="num">34</td>
<td class="num">17.0</td>
<td class="date">12/17/2008</td> <!-- if you are playing with dates too -->
Update: Additional formatting options from @Aaron.
Here is a list of Excel formats: Styling Excel cells with mso-number-format