I am exporting the contents of SP to excel. One of the columns brings the date format as 08/2015 but when exporting to excel, the format gets changed to Aug-2015.
I
Here is some sample code.
Response.AddHeader("content-disposition", "attachment; filename=Report.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
DataGrid g = new DataGrid();
DataTable d = new System.Data.DataTable();
d = (DataTable)Session["ReportData"];
g.DataSource = d;
g.DataBind();
foreach (DataGridItem i in g.Items)
{
foreach (TableCell tc in i.Cells)
tc.Attributes.Add("class", "text");
}
g.RenderControl(htmlWrite);
string style = @" ";
Response.Write(style);
Response.Write(stringWrite.ToString());
Response.End();