gridview 导出到EXCEL,导出数据时一条的话就能看到数据,是多条数据导出来excel里面就是空白,代码显示是有数据的,
excel 的大小都有~!
excel 的大小都有~!
解决方案 »
- 哪种写法好?
- C#下载数据库里的文件
- 客户端发现响应内容类型为“text/html; charset=utf-8”,但应为“text/xml”。
- 项目怎么调试?
- 请问众大哥学习.NET以后的出路....
- 看下这段代码,为什么一直都是提示else后面的代码?
- [求助] VS2005.NET下发送邮件的示例代码
- <%# DataBinder.Eval(Container.DataItem, "adopt")%> 问题!!
- 请问"没有强名称"是什麽意思?该怎麽解决?ibankadventure.dll是我引用的组件.
- 页面怎么防止后退?
- 如何提取所有图像文件
- 求助:我在Asp.net的后台代码中写入Cookie,可是前台用JQuery取不出来
{
HttpContext.Current.Response.Charset = "GB2312";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;//
HttpContext.Current.Response.AppendHeader("Content-Disposition",
"attachment;filename=" + DateTime.Now.ToShortDateString() + ".xls");
HttpContext.Current.Response.ContentType = "application/ms-excel";//image/JPEG;text/HTML;image/GIF;vnd.ms-excel/msword
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
gvCustomerAnalysis.RenderControl(hw);
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
}
困扰我2天了
//转EXCEL
protected void BtnExcel_Click(object sender, EventArgs e)
{
Export("application/ms-excel", "Detail.xls");
}
private void Export(string FileType, string FileName)
{
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.AppendHeader("Content-Disposition", "attachment;filename=" + FileName);
Response.ContentType = FileType;
this.EnableViewState = false;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
GridView1.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();
}
public override void VerifyRenderingInServerForm(Control control)
{
}
public override void VerifyRenderingInServerForm(Control control)
{
}