本文介绍了如何在将gridview数据导出到Excel时删除页脚..?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Helo朋友。

在我的网站上我输出gridview数据excel.but问题是gridview页脚也在excel中导出...我不想在excel中导出..如何做到了吗?

thx提前..

Helo friends.
In my website i m exporting gridview data excel.but the problem is gridview page footer also get exported in excel...i dont want to export that in excel..how to do it??
thx in advance..

推荐答案

private void ExportGridView()
        {
            //gvFiles.ShowFooter = false;
            System.IO.StringWriter sw = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter htw = new System.Web.UI.HtmlTextWriter(sw);

            gvFiles.FooterRow.Visible = false;

            // Render grid view control.
            gvFiles.RenderControl(htw);

            // Write the rendered content to a file.
            string renderedGridView = sw.ToString();
            File.WriteAllText(@"D:\Suresh\ExportedFile.xls", renderedGridView);

           // gvFiles.ShowFooter = true;
            gvFiles.FooterRow.Visible = true;
        }



这篇关于如何在将gridview数据导出到Excel时删除页脚..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 05:15