本文介绍了如何使用Datalist导出受密码保护的excel文件..以下是我的代码...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  string  attachment =   attachment; filename = detail.xls; 
Response.ClearContent();
Response.AddHeader(
password 1234 );
Response.AddHeader(
content-disposition ,附件);
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 ] =服务器 ;
frm.Controls.Add(DataList1);
frm.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();









已添加 pre 标签。

[/编辑]

解决方案



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();




[Edit member="Tadit"]
Added pre tags.
[/Edit]

解决方案



这篇关于如何使用Datalist导出受密码保护的excel文件..以下是我的代码...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 20:32