Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

CrystalDecisions.CrystalReports.Engine.ReportDocument.Export(ExportOptions options) Throwing Exception

Works on Development box. Windows 7 64bit.

Not working on Deployed Server 2012 R2 64bit

Crystal Reports version 13_0_13.

2015-06-08 11:21:25,692 [7] FATAL DecalPrintWCWindowsService.clsDecal [(null)] - CreateDecalPDF:
System.Runtime.InteropServices.COMException (0x80004005): The system cannot find the path specified.

   at CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export(ExportOptions pExportOptions, RequestContext pRequestContext)
   at CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext)
   at CrystalDecisions.CrystalReports.Engine.FormatEngine.ExportToStream(ExportRequestContext reqContext)
   at CrystalDecisions.CrystalReports.Engine.FormatEngine.Export(ExportRequestContext reqContext)
   at CrystalDecisions.CrystalReports.Engine.ReportDocument.Export(ExportOptions options)
   at DecalPrintWCWindowsService.clsDecal.CreateDecalPDF()

Code Snippet:

                ReportDocument objCR_ReportDoc = new ReportDocument();
                DiskFileDestinationOptions objDiskFileDestinationOptions;
                ExportOptions objExportOptions;

                objCR_ReportDoc.Load(sTemplatePath);

                objDiskFileDestinationOptions = new DiskFileDestinationOptions();
                objExportOptions = objCR_ReportDoc.ExportOptions;
                objExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                objExportOptions.ExportFormatOptions = null;
                objExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
                objDiskFileDestinationOptions.DiskFileName = msPDFPath + PDFFileName;
                WriteLine(msPDFPath + PDFFileName);
                objExportOptions.ExportDestinationOptions = objDiskFileDestinationOptions;
                objCR_ReportDoc.Export(objExportOptions);
                objCR_ReportDoc.Dispose();

It is exploding (throwing exception) at the second to last line... objCR_ReportDoc.Export(objExportOptions);

I have been researching this issue for several days, tried most all suggestions from this site and others, to no avail.

Any thoughts?

John

replied

Hi Guys,

An exception is going to be thrown if the report does not have that export option saved in it.

So simply use a try/catch block and the collection is Null then it means the saved export options have not been saved in the RPT.

Like so...

CrystalDecisions.ReportAppServer.ReportDefModel.ExportOptions RASexportOpts = new CrystalDecisions.ReportAppServer.ReportDefModel.ExportOptions();
CrystalDecisions.ReportAppServer.ReportDefModel.CharacterSeparatedValuesExportFormatOptions RasCSVExptOpts = new CharacterSeparatedValuesExportFormatOptions();
CrystalDecisions.ReportAppServer.ReportDefModel.DataOnlyExcelExportFormatOptions RasExcelDataOnlyExpOpts = new DataOnlyExcelExportFormatOptions();
CrystalDecisions.ReportAppServer.ReportDefModel.EditableRTFExportFormatOptions RasEditRTFExpOpts = new CrystalDecisions.ReportAppServer.ReportDefModel.EditableRTFExportFormatOptions();
CrystalDecisions.ReportAppServer.ReportDefModel.ExcelExportFormatOptions RasXLSExpOpts = new ExcelExportFormatOptions();

CrystalDecisions.ReportAppServer.ReportDefModel.PaginatedTextExportFormatOptions RasPaginTextExpOpts = new PaginatedTextExportFormatOptions();
CrystalDecisions.ReportAppServer.ReportDefModel.PDFExportFormatOptions RasPDFExpOpts = new PDFExportFormatOptions();
CrystalDecisions.ReportAppServer.ReportDefModel.RPTExportFormatOptions RasRPTExpOpts = new RPTExportFormatOptions();
CrystalDecisions.ReportAppServer.ReportDefModel.RTFWordExportFormatOptions RasRTFWordExpOpts = new RTFWordExportFormatOptions();
CrystalDecisions.ReportAppServer.ReportDefModel.TextExportFormatOptions RastxtExpOpts = new TextExportFormatOptions();
CrystalDecisions.ReportAppServer.ReportDefModel.XMLExportFormatOptions RasXMLExpOpts = new XMLExportFormatOptions();
CrystalDecisions.ReportAppServer.ReportDefModel.IndentAndSpacingFormat RasIndentSpaceExpOpts = new IndentAndSpacingFormat();

string textBox1 = String.Empty;
string MyObjectType = ReportObjectComboBox1.SelectedItem.ToString();
btnReportObjects.Text = "";

foreach (CrystalDecisions.ReportAppServer.ReportDefModel.CrReportExportFormatEnum SavedExpType in valArray1)
{
    switch (SavedExpType.ToString())
    {
        case "crReportExportFormatCrystalReports":
            try
            {  
                RasRPTExpOpts = rptClientDoc.get_SavedExportOptions(CrReportExportFormatEnum.crReportExportFormatReportDef);
                textBox1 = "RPT Format: \n";
                textBox1 += "DiscardUnselectedRecords: " + RasRPTExpOpts.DiscardUnselectedRecords.ToString() + "\n";
                textBox1 += "BaseAreaGroupNumber:       " + RasRPTExpOpts.EndPageNumber.ToString() + "\n";
                textBox1 += "BaseAreaType:              " + RasRPTExpOpts.StartPageNumber.ToString() + "\n";
            }
            catch (Exception ex)
            {
                textBox1 = "RPT Format Options - Not saved\n";
                btnReportObjects.Text += textBox1;
                btnReportObjects.AppendText(" 'End' \n\n");
                textBox1 = "";
                break;
            }

            btnReportObjects.Text += textBox1;
            btnReportObjects.AppendText(" 'End' \n\n");
            textBox1 = "";
            break;
...

Don

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question