export to excel issue

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am pasting sample code below which I call on a button click. My problem is
that 6/7 is shown by excel as 7-Jun. I want it to look as 6/7 in excel.
Please let me know if anyone has a solution.

Thanks

string temp = "<html><table><tr><td>6/7</label></td></tr></table></html>";
Response.Clear();
Response.Buffer= true;
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment; filename=test.xls");
Response.ContentEncoding = System.Text.Encoding.UTF7;
Response.Charset = "";
EnableViewState = false;
Response.Write(temp);
 
Add a single quote ' before the 6/7. That will indicate you want text rather
than the Excel tendency to treat it as a date.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com/

*************************************************
Think Outside the Box!
*************************************************
 
Hi
Thanks for the reply. However if I add a quote it will show '6/7 in
excell cell. It doesn't look nice. Is there any way I can achieve this
without showing any other character in the cell.

Thanks
 
Back
Top