Problem with an Excel file

see07

Regular
Joined
Apr 16, 2004
Messages
78
Location
Mexico City
I’m creating an Excel file (.xls) and showing it into a web page, I’m using this code:

Response.Clear();
Response.Buffer= true;
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "inline;filename=Clientes.xls");
Response.Charset = "";
this.EnableViewState = false;
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
DataGrid1.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();

When code finish it execution, a window is displayed, asking user if he want open or save the file, if he choose save, file is saved as Clientes.xls in folder user choose. But when user decide open file it is opened into a web form containing rows and columns as an excel file, if user modify some data and close web form, system tell user that this document have changed and ask if he wants to save it, if answer is yes, and an automated window is displayed containing file name (in blank) and type of save containing (web page), and user need to place file name and change type of save from web page to Microsoft Excel Book.
Does somebody know how to achieve this automated window be filled in file name with Clientes.xls and type of save be filled with Microsoft Excel Book?
I’ll appreciate your help.
A.L.
 
Back
Top