导出到pdf asp.net时的水晶报告错误c#

时间:2016-04-28 10:08:58

标签: c# asp.net crystal-reports

我正在使用以下代码处理crystal report export pdf,但是当导出为pdf时,错误将出现在第9行。

  

错误:找不到方法:'CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag CrystalDecisions.ReportAppServer.ReportDefModel.ISCRExportOptions.get_ExportOptionsEx()'。

    ReportDocument crystalReport = new ReportDocument();
    crystalReport.Load(Server.MapPath("FrontRor_S.rpt"));
    DataSet ds = GetData();
    DataTable dt = new DataTable();
    dt = ds.Tables[0];
    crystalReport.SetDataSource(dt);
    CrystalReportViewer1.ReportSource = crystalReport;
    ExportFormatType formatType = ExportFormatType.PortableDocFormat;
    crystalReport.ExportToHttpResponse(formatType, Response, true, "Crystal");
    Response.End();

1 个答案:

答案 0 :(得分:0)

                    ExportOptions CrExportOptions ;
                    DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
                    PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions();
                    CrDiskFileDestinationOptions.DiskFileName = "C:\\SampleReport.pdf";
                    CrExportOptions = doc.ExportOptions;
                    {
                        CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                        CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
                        CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
                        CrExportOptions.FormatOptions = CrFormatTypeOptions;
                    }
                    doc.Export();

请在crystalReport.SetDataSource(dt);之后试用此代码 这肯定会奏效。