如何在Excel工作表中导出数据? [英] How to export data in excel sheet?
本文介绍了如何在Excel工作表中导出数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我想在excel表格中导出数据,这些数据在gridview中显示。
我放了一些代码行,但它给出了如下错误:
请帮助我。
无法评估表达式,因为代码已优化或本机框架位于调用堆栈之上。
这是我的代码块:
Hi All,
I want to export data in excel sheet which are display in gridview.
I put some code line but it give an error as follows:
Please help me for the same.
Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.
This is my Code block:
try
{
string attachment = "attachment; filename=Export.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
HtmlForm frm = new HtmlForm();
GRD_Final_Report.Parent.Controls.Add(frm);
frm.Attributes["runat"] = "server";
frm.Controls.Add(GRD_Final_Report);
frm.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
}
Catch(Exception ex)
{
}
推荐答案
通过这些链接
从C#中的GridView导出到Excel中[ ^ ]
在ASP.NET C#中导出到Excel [ [^ ]
Go through these links
Export to Excel from GridView in C#[^]
Export to Excel in ASP.NET C#[^]
这篇关于如何在Excel工作表中导出数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文