从GridView导出PDF的问题 [英] Problem with export pdf from gridview

查看:67
本文介绍了从GridView导出PDF的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iTextsharp dll从gridview导出pdf.
它不会显示gridview中的所有记录,它只显示当前页面记录,但是我想显示所有页面记录.

请帮帮我.

I am using iTextsharp dll for export pdf from gridview.
It doesn''t display the all records from gridview, it displays only current page record, but i want to display all page records.

Please Help me.

Thanks in advance.

推荐答案

此代码段在Button click事件中生成PDF报告.为此,我采用了一个动态网格,然后将其绑定到HTML代码中,因为用于生成PDF我们必须先制作HTML代码,然后尝试使用此方法,我认为您已经找到了解决方案.
This code snippets generate the PDF report on Button click event.For that I taken one dynamic grid then bind it into HTML code because for generating PDF we have to Make HTML code first try this I think u got solution.
protected void PrintReportButton_Click(object sender, EventArgs e)
    {
       
        #region DataGrid Bind

        DataGrid grdFinal = new DataGrid();


        objClientReportBL._ClientReportId = Request.QueryString["ClientReportId"].ToString();
        objClientReportBL.Reportdata();

        grdFinal.DataSource = objClientReportBL.ds.Tables[0];
        grdFinal.DataBind();

        Response.Buffer = true;
        Response.ClearContent();
        Response.ClearHeaders();
        #endregion

        #region ERROR Method
       Response.ContentType = "application/vmd.pdf";
       

        Response.AddHeader("content-disposition", "attachment;filename=ClientReport.pdf");
       

        EnableViewState = false;


        using (StringWriter sw = new StringWriter())
        {
            HtmlTextWriter hw = new HtmlTextWriter(sw);

            grdFinal.RenderControl(hw);

            Response.Write(sw.ToString());
            Response.Flush();
            //    Response.Close();
            Response.End();
        }
        #endregion
    }


此链接将为您提供帮助:)
使用iTextsharp将gridview导出为pdf [
this link will help you :)
Export gridview to pdf using iTextsharp[^]


嗨... Ankit ...
对于该功能,必须将所有数据转换为HTML,然后才能继续,然后必须下载COM库...并且有一个类名是PDFMANAGER,使用它可以安排PDF ...您可以从http获取此COM库. ://www.asppdf.com/.....试试这个..
------------------------------------
祝您有个美好的一天
如果方便,请投票.....上
Hi...Ankit...
For that functionality have to convert all the data into HTML then u can proceed then u have to download COM library...and there is one class name is PDFMANAGER using that u can Arrange PDF...this COM library u can get from http://www.asppdf.com/ ..... try this..
------------------------------------
HAVE A NICE DAY
IF IT HELPS PLEASE VOTE IT.....up


这篇关于从GridView导出PDF的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆