Forcing numeric values as text on HTML table exporting to excel Forcing numeric values as text on HTML table exporting to excel asp.net asp.net

Forcing numeric values as text on HTML table exporting to excel


Just add one line before your table

Response.Write("<style> TD { mso-number-format:\@; } </style>");

Check this out: Export Gridview to Excel with rows formatted as text


Maybe try ="00212704"

Response.Write("<td class='tdsmall' align='left' NOWRAP>=""" & rsPODetail("ITM_ID") & """</td>")


One option that doesn't require modifying the content of the tables is to use the mso-number-format CSS style, as described on this SO answer. For text, you would use something like:

CSS:

.xlText {    mso-number-format: "\@";}

HTML:

<td class="xlText">00030</td>