ASP.NET:将数据从GridView导出到Excel的第三方插件

ASP.NET:将数据从GridView导出到Excel的第三方插件,asp.net,excel,gridview,export-to-excel,Asp.net,Excel,Gridview,Export To Excel,已使用此方法导出excel文件: HttpContext.Current.Response.Clear(); HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Single_Raw.xls")); HttpContext.Current.Response.ContentType = "application

已使用此方法导出excel文件:

HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Single_Raw.xls"));
        HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
using (StringWriter sw = new StringWriter())
{
    using (HtmlTextWriter htw = new HtmlTextWriter(sw))
    {
       // some code

        HttpContext.Current.Response.Write(sw.ToString());
        HttpContext.Current.Response.End();
    }
}
但是这种方法有很大的局限性,每次我打开Excel文件时,Excel都会显示此警告:

HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Single_Raw.xls"));
        HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
using (StringWriter sw = new StringWriter())
{
    using (HtmlTextWriter htw = new HtmlTextWriter(sw))
    {
       // some code

        HttpContext.Current.Response.Write(sw.ToString());
        HttpContext.Current.Response.End();
    }
}
您试图打开的文件<>的格式与文件扩展名指定的格式不同。打开文件之前,请确认文件未损坏且来源可靠。是否立即打开该文件?

我建议的第二种方法是使用互操作,但也有一些限制:

http://www.gemboxsoftware.com/LA/Excel-Automation-and-Excel-Interop.htm

其中之一是所有客户机的计算机都应该具有相同的Excel版本


现在我正在拼命寻找其他方法,即使这意味着使用第三方插件。只要它是免费的并且可以在公司网站上使用。

使用:LumenWorks.Framework.IO.Csv