Exception while exporting the report RRS feed

  • Question

  • User1315566951 posted

    Hello Everyone,

    I am new to crystal reports in asp.net with c#. report is working fine. but export and next page navigation is not working. for export i wrote a code as below in the click event of button which i have created,

    string exportFileName = "Questionaswer.rpt"; 
    string exportPath = "C:\\crystalreport1.pdf"; //where file will be exported
    string path = Server.MapPath("~/Quiz/Questionaswer.rpt");
    ReportDocument crReportDocument = new ReportDocument();

    ExportOptions crExportOptions;

    DiskFileDestinationOptions crDestOptions = new DiskFileDestinationOptions();

    crDestOptions.DiskFileName = exportPath;

    crExportOptions = crReportDocument.ExportOptions;

    crExportOptions.DestinationOptions = crDestOptions;
    //Specify export destination type

    crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
    // Specify the format in which you want to export (like .doc,.pdf etc)

    crExportOptions.ExportFormatType = ExportFormatType.CrystalReport;

    In this export method , system.runtime.interopservices error is coming and it is taking the path of report from temp folder. 
    also i have tried the solution of giving the rights to the folder where this pdf will be created. but doesnt work. also i have tried exporttodisk() method.
    but same exception is coming. please tell me the solution of this.
    Thanks in Advance
    Tuesday, December 20, 2011 7:26 AM

All replies

  • User-102500655 posted

    please try this

    string exportPath = "C:\\crystalreport1.pdf"; //where file will be exported  
     ExportOptions CrExportOptions;
                DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
                PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions();
                CrDiskFileDestinationOptions.DiskFileName = pdfFile;
                CrExportOptions = rpt.ExportOptions;
                CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
                CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
                CrExportOptions.FormatOptions = CrFormatTypeOptions;
    try this if not working then debug your code and tell me from where its throughing error
    Thursday, December 22, 2011 5:11 AM
  • User-102500655 posted

    one more thing make sure your report is loaded correctly when you are trying to export it...

    for this you have keep an eye on post back ..Smile

    Thursday, December 22, 2011 5:13 AM