string attachment = "attachment; filename=detail.xls; Response.ClearContent(); Response.AddHeader("password", "1234"); Response.AddHeader("content-disposition", attachment); Response.ContentType = "application/ms-excel"; StringWriter sw = new StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); HtmlForm frm = new HtmlForm(); DataList1.Parent.Controls.Add(frm); frm.Attributes["runat"] = "server"; frm.Controls.Add(DataList1); frm.RenderControl(htw); Response.Write(sw.ToString()); Response.End();
pre
Quote:The way you are generating excel file is not actully a excel file. it's a html file which is displayed in excel and nothing wrong in it, as it fullfil most of the requriements. But if you want to generate the password protected excel file, then you have to generate the real excel file. These links might be usefull to you: Implementing Password Security on Excel Workbooks Using Visual Studio .NET[^] http://social.msdn.microsoft.com/Forums/en-US/os_specifications/thread/7021768e-4562-43dd-9d5e-89c10970bf33/[^] or just search internet for any third party paid/free component.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)