如何将数据从datagrid导出到html文件 [英] how to export data from datagrid to html file
本文介绍了如何将数据从datagrid导出到html文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想编码用于将数据从datagrid导出到html文件中的代码
-Dhammaratna
i want to code for exporting the data from datagrid to html file
-Dhammaratna
推荐答案
不支持直接导出,您应该通过代码
查找每个单元格值和生成html 如果要直接导出,则可能需要3d派对应用程序,例如 http://xceed.com
direct exporting is not supported you should seek each cell value and the build html by code
if you want direct exporting you may need a 3d party application such as form http://xceed.com
Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");
Response.Buffer = true;
//want to export into excel
Response.ContentType = "application/vnd.xls";
//want to export into HTML
Response.ContentType = "application/vnd.Html";
Response.Charset = "";
EnableViewState = false;
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
ClearControls(grd);
grd.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();
这篇关于如何将数据从datagrid导出到html文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文