报告查看器控件将内容导出为pdf

时间:2012-06-25 07:10:01

标签: c# asp.net pdf reportviewer

我正在为客户创建asp.net net app,他喜欢在他的页面上有报告,所以我在页面rdlc文件上使用默认的asp.net报表查看器控件在页面上显示此文件。 。一切都没问题,除非客户想要将文件保存为pdf页面的结构发生变化而且看起来不一样我也注意到字段中的某些值为空但它们出现在页面上并且当我保存时Word(*。doc)格式的同一报告也就像文件应该是这样......问题只有pdf。欢迎任何建议

2 个答案:

答案 0 :(得分:5)

问题是由于报告属性中的边距设置,如果遇到同样的问题,请将边距设置(左,右,上,下)设置为0in。你的问题就解决了。

答案 1 :(得分:0)

尝试此代码....它将有助于以pdf格式显示数据

    protected void submit_Click(object sender, EventArgs e)
    {
        bindReportData();  
        try
        {
            // Export the Report to Response stream in PDF format and file name Customers

            abc_reportDocument.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "ABC");
            // There are other format options available such as Word, Excel, CVS, and HTML in the ExportFormatType Enum given by crystal reports
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            ex = null;
        }
    }



    private void bindReportData()
    {
        abc_reportDocument = new ReportDocument();
        dsReport = new DataSet();
        dsReport = getAccumulationData();
        if (dsReport.Tables[0].Rows.Count > 0)
        {
            abc_reportDocument.Load(this.MapPath("report1.rpt"));
            abc_reportDocument.Database.Tables[0].SetDataSource(dsReport.Tables[0]);
            rptviewerAccumulation.ReportSource = abc_reportDocument;
            rptviewerAccumulation.DataBind();


        }

}