乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > -repeater 导出excel,导出excel

-repeater 导出excel,导出excel

作者:乔山办公网日期:

返回目录:excel表格制作







这个很简单啦,我在项目中使用了,你把我下面这段代码copy到你项目中:
注解:rpt_pro是Repeater控件名,你改成你自己的,另外,你在页面中加一个导出按钮
<asp:Button ID="btnInputExcel" runat="server" Width="50" Text="导 出" onclick="btnInputExcel_Click"/>
/// <summary>
/// 导出数据函数
/// </summary>
/// <param name="FileType">导出文件7a686964616fe78988e69d83331MIME类型</param>
/// <param name="FileName">导出文件的名称</param>
private void Export(String FileType, String FileName)
{
Response.Clear();
Response.BufferOutput = true;
//设定输出字符集
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.AppendHeader("Content-Disposition", "attachment;filename="
+ HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8));
//设置输出流HttpMiME类型(导出文件格式)
Response.ContentType = FileType;
//关闭ViewState
Page.EnableViewState = false;
System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo("ZH-CN", true);
System.IO.StringWriter stringWriter = new System.IO.StringWriter(cultureInfo);
HtmlTextWriter textWriter = new HtmlTextWriter(stringWriter);
rpt_pro.RenderControl(textWriter);
//把HTML写回游览器
Response.Write(stringWriter.ToString());
Response.End();
Response.Flush();
}

//确认在运行时为指定的 ASP.NET 服务器控件呈现在 HtmlForm 控件中。
//(检验Asp.Net服务器空间是否呈现在HTMLForm控件中)
public override void VerifyRenderingInServerForm(System.Web.UI.Control control)
{
}

#region 导出成Excel
protected void btnInputExcel_Click(object sender, EventArgs e)
{
Export("application/ms-excel", "员工评分表.xls");
}
#endregion

导出成word的话,你可以另外加一个按钮
#region 导出成Excel
protected void btnInputWord_Click(object sender, EventArgs e)
{
Export("application/ms-word", "员工评分表.doc");
}
#endregion

相关阅读

  • -repeater 导出excel,导出excel

  • 乔山办公网excel表格制作
  • 这个很简单啦,我在项目中使用了,你把我下面这段代码copy到你项目中:注解:rpt_pro是Repeater控件名,你改成你自己的,另外,你在页面中加一个导出按钮
  • -名片王 导出 excel,导出excel

  • 乔山办公网excel表格制作
  • 名片全能抄王导出excel步骤:1、打开名片全能王以后,点击右上角的“多选”按钮,2、接下来请选择要导出的名片,再点击右下角的“更多”选项按钮,3、随后请选择从底部弹出的“导
关键词不能为空
极力推荐
  • 如何快速破解<em>2007excel</em>的<em>密码</em>

  • excel2007打开密码" src="/uploads/tu/528.jpg" style="width: 400px; height: 267px;" />工具:EXCEL 2007步骤:1、首先备份工copy作簿,修改工作簿文件的扩展名为zip。2、解压该压缩文件。找到代表目标工作表

ppt怎么做_excel表格制作_office365_word文档_365办公网