dinilkarun 8 Posting Whiz in Training

I'm trying to export a grid view to an excel sheet, but am not able to set the column type in the excel sheet.
The following is the code I am using to export to excel:

string attachment = "attachment; filename=CandidatesToBePlaced_Payloads.xls";
          Response.ClearContent();
          Response.AddHeader("content-disposition", attachment);
          Response.ContentType = "application/ms-excel";
          StringWriter sw = new StringWriter();
          HtmlTextWriter htw = new HtmlTextWriter(sw);

          // Create a form to contain the grid
          HtmlForm frm = new HtmlForm();
          dgProfilesToBePlaced.Parent.Controls.Add(frm);
          frm.Attributes["runat"] = "server";
          frm.Controls.Add(dgProfilesToBePlaced);
          frm.RenderControl(htw);

          //dgProfilesToBePlaced.RenderControl(htw);
          Response.Write(sw.ToString());
          Response.End();

One column in the grid view after exporting to excel is displayed in date format, while i want it to be retained as number.

TIA
Dinil

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.