Through mine functionality of ASP.Net, I could export all available data from Data Grid to Excel file but I need to write those data to a specific excel file which is located in Web folder. sample code I had given below for your better understanding
Response.Clear();
Response.ClearContent();
Response.Charset = "";
Response.ContentType = "application/vnd,xls";
Response.AppendHeader("content-disposition", "attachment; filename=Ex.xls");
DataGrid1.DataSource = ExportTbl;
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
DataGrid1.DataBind();
DataGrid1.RenderControl(hw);
Response.Write(sw.ToString());
Response.End();
Response.Clear();
Response.ClearContent();
Response.Charset = "";
Response.ContentType = "application/vnd,xls";
Response.AppendHeader("content-disposition", "attachment; filename=Ex.xls");
DataGrid1.DataSource = ExportTbl;
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
DataGrid1.DataBind();
DataGrid1.RenderControl(hw);
Response.Write(sw.ToString());
Response.End();
0 comments:
கருத்துரையிடுக