We generate an Excel spreadsheet in our C# .net website by writing out an HTML table to Response. This works great, but the sheet name gets set to the same as the file name.
Is there away to set this? We require a certain sheet name when importing.
Code:
string filename = String.Format( "{0}-CopyDataBack_{1}.xls", Master.EventID.ToString(), DateTime.Now.ToString( "dd-MM-yy_HHmm" ) );
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("content-disposition", "attachment;filename=" + filename );
Response.Charset = "";
this.EnableViewState = false;
System.Text.StringBuilder tableOut = new System.Text.StringBuilder();
// ... Create an HTML table in a StringBuilder ...
Response.Write( tableOut );
Response.End();