简体   繁体   English

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

[英]report viewer control exporting content to pdf

I am creating asp.net net app for a client and he likes to have reports on his page so i have on the page rdlc file and im using default asp.net report viewer control to present this file on the page...everything is ok except when the client wants to save the file as pdf the structure of the page changes and it doesnt look the same also i have notice that some of the values in fields are empty but they appear on the page and when im saving the same report in Word(*.doc) format also the word file is like it should be...the problem is only with the pdf. 我正在为客户创建asp.net网络应用程序,他喜欢在他的页面上有报告,所以我在页面rdlc文件上,我使用默认的asp.net报表查看器控件在页面上显示此文件...一切都是好的,除非客户端想要将文件保存为pdf时页面的结构发生变化并且看起来不一样我也注意到字段中的某些值为空但它们出现在页面上并且当我保存相同的报告时在Word(*。doc)格式中,单词文件也应该是......问题仅在于pdf。 Any suggestions are welcome 欢迎任何建议

The problem was due to the Margins settings in the Report Properties if you are having the same problem set the Margins settings (Left,Right,Top,Bottom) to 0in. 问题是由于报告属性中的边距设置,如果您遇到相同的问题,请将边距设置(左,右,上,下)设置为0in。 And your problem is solve. 而你的问题就解决了。

Try out this code.... it will help to displayy ur data in pdf format 试试这个代码....它将有助于以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();


        }

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM