在ASP.NET中通过两个DataGrid和两个工作表导出一个Excel [英] Export one excel by two datagrid with two sheet in asp.net
本文介绍了在ASP.NET中通过两个DataGrid和两个工作表导出一个Excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个datagrid,我想在这个excel文件中创建excel文件,我想创建两个工作表,每个数据网格在excel中都有每个工作表.
我使用此功能
I have two datagrid , i want to create excel file in this excel file i want to create two sheet each data grid have each sheet in excel.
i use this function
DataGrid dg1,dg2;
protected void Export(DataGrid dg1, string name)
{
Response.Clear();
string filename = name + DateTime.Now.Date.ToString("dd-MM-yyyy") + ".xls";
Response.AddHeader("content-disposition", "attachment;filename=" + filename);
Response.Charset = "";
// If you want the option to open the Excel file without saving than
// comment out the line below
// Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite =
new HtmlTextWriter(stringWrite);
dg1.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
}
推荐答案
请仔细阅读
http://vbcity.com/forums/t/162486.aspx
http://stackoverflow.com/questions/7632782/export-gridview-to-multiple- excel-sheet
http://forums.asp.net/t/1611177.aspx/1
http://stackoverflow.com/questions/3053524/export-2-gridview-to-2-worksheets-single-excel-with-formatting
Please go through this
http://vbcity.com/forums/t/162486.aspx
http://stackoverflow.com/questions/7632782/export-gridview-to-multiple-excel-sheet
http://forums.asp.net/t/1611177.aspx/1
http://stackoverflow.com/questions/3053524/export-2-gridview-to-2-worksheets-in-single-excel-with-formatting
这篇关于在ASP.NET中通过两个DataGrid和两个工作表导出一个Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文