Skip to Content
avatar image
Former Member

Call to rpt.ExportToDisk Is Very Slow To Return

Hi,

I've recently upgraded my Crystal Reports runtime to the latest versions as found at the below URL:

https://wiki.scn.sap.com/wiki/display/BOBJ/Crystal+Reports%2C+Developer+for+Visual+Studio+Downloads

Before making this change, we were experiencing very slow performance within the API when the following method is called:

rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.CrystalReport, filename)

After updating the runtime and running a test, there is still an almost two-minute delay before this method returns. Can you tell us if there is anything we can do to attempt to speed the performance up some? We are looking to upgrade to the latest version of Crystal, but first we would like to verify any performance gains we could expect to receive through doing so.

For reference, I have also opened ticket number 1000045636 as an inquiry into the upgrade and have been testing the trial version of Crystal Reports 2016.

Thank you for any help you may be able to provide.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Jul 07, 2017 at 09:41 PM

    Do not use Crystal Reports to archive your database, exporting that much data is actually quite impressive for that size of a report file.

    I suggest you have a closer look at the report, that size seems quite large.

    Are there embedded images in the report? Those can consume a huge amount of memory and space.

    Try using RAS to do the exporting, I don't believe it will improve but something to try:

    CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
    CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument rptClientDoc;

    if (ExportTypeSelected == "crReportExportFormatCrystalReports")
    #region RPT
    {
    // This works do not alter
    // this gets the report name and sets the export name to be the same less the extension
    string outputFileName = "";
    string MyRptName = rpt.FileName.ToString();
    outputFileName = MyRptName.Substring(9, rpt.FileName.Length - 9);
    outputFileName = outputFileName.Substring(0, (outputFileName.Length - 4)) + "1.rpt";

    try
    {
    if (File.Exists(outputFileName))
    {
    File.Delete(outputFileName);
    }

    CrystalDecisions.ReportAppServer.ReportDefModel.RPTExportFormatOptions RasRPTExpOpts = new RPTExportFormatOptions();

    try
    {
    RasRPTExpOpts = rptClientDoc.get_SavedExportOptions(CrReportExportFormatEnum.crReportExportFormatCrystalReports);
    }
    catch (Exception ex)
    {
    btnSQLStatement.Text = "ERROR: " + ex.Message;
    //return;
    }

    // Set them now:
    //RasPDFExpOpts.CreateBookmarksFromGroupTree = false;
    //RasPDFExpOpts.EndPageNumber = 1;
    //RasPDFExpOpts.StartPageNumber = 1;

    CrystalDecisions.ReportAppServer.ReportDefModel.ExportOptions exportOpts1 = new CrystalDecisions.ReportAppServer.ReportDefModel.ExportOptions();
    exportOpts1.ExportFormatType = CrReportExportFormatEnum.crReportExportFormatCrystalReports;
    exportOpts1.FormatOptions = RasRPTExpOpts;

    // And Export
    rptClientDoc.PrintOutputController.ExportEx(exportOpts1).Save(outputFileName, true);
    MessageBox.Show("Export to RPT Completed. NOTE: report is *1.RPT", "", MessageBoxButtons.OK, MessageBoxIcon.Information);

    }
    catch (Exception ex)
    {
    btnSQLStatement.Text = "ERROR: " + ex.Message;
    return;
    }
    // This works do not alter
    }

    #endregion RPT

    Don

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 21, 2017 at 08:57 PM

    Hi Gene,

    If you run the report and preview the report instead of exporting, how fast does the report take to come up? How long does it take to go to the last page?

    If the report takes 2 minutes to come up and generate to the last page then you will need to look closer at the report.

    If the preview comes up quickly then we can look at your exporting procedure.

    Are you exporting locally or to a network folder?

    How large is the file after it completes?

    How much resources are on the machine running the report? This is important if you're exporting because the temp file needs to be created before the final report is saved.

    Thanks,

    Brian

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Gene,

      How many subreports and where on the main report are they located?

      Subreports can be a huge performance hit because each time a subreport is called, it queries the database again. So if a subreport is in the Detail section, it will query the database for each record in the report. If you have a lot of records, imagine how hard the report is hammering your database.

      Having the subreports query against your database is a good step. In some cases, I've had to write a stored procedure that returns the data for the main and subreport in one execution. The database will always be faster than Crystal so pushing as much of the processing onto the database will make things faster. This does depend on how your data is structured, how your report is formatted and whether it makes sense to combine the queries.

      If your subreports are hitting the tables directly, could you optimize the queries by using a view or stored procedure to reduce the number of records the subreports need to process?

      An example of how subreports can make a report inefficient, I once had a report with 2 subreports. It would take 8+ hours to complete. So it had to be scheduled in the evening after the database backup. When I broke the report down, the performance hit was happening because one of the subreports took about 10 - 15 seconds to run. Multiple that by 3,000 times and you get 8.3 to 12.5 hours.

      I removed the subreports and coded everything into a Stored Procedure. That took the report from 8+ hours to about 10 minutes. Still not great but the complexity of the data prevented me from getting it any faster and well enough that the users could run the report during the day.

      Hope this helps,

      Brian