Skip to Content
avatar image
Former Member

Exporting Crystal Reports to Excel in VS 2012

Hi,


In our web application developed in Visual Studio 2012, when I try to export crystal reports, I am getting the following error:

Method not found: 'CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag CrystalDecisions.ReportAppServer.ReportDefModel.ISCRExportOptions.get_ExportOptionsEx()'


It used to work fine in Visual Studio 2008, exporting to Pdf, Word & Excel.

It was also working fine exporting to Pdf & Word in the Visual Studio 2012 application using crystal reports 2008.

But it would not work for Excel.

So in an effort to get it working I installed Crystal Reports 2013 and downloaded the latest visual studio developer version (Support Pack 12) from this site:

SAP Crystal Reports, developer version for Microsoft Visual Studio: Updates & Runtime Downloads

(I've tried Support Pack 10 also).



My code is quiet straightforward, here is a shortened version of it:


Imports CrystalDecisions.CrystalReports.Engine

Imports CrystalDecisions.Shared

.

.

.

Dim Report As New ReportDocument

Report.Load(reportPath + reportName)

Report.FileName = reportPath + reportName

Report.Database.Tables(0).SetDataSource(dataTableName)

Dim oStream As New MemoryStream

oStream = CType(Report.ExportToStream(ExportFormatType.PortableDocFormat), MemoryStream)

On the last line above, it throws the following error:

Method not found: 'CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag CrystalDecisions.ReportAppServer.ReportDefModel.ISCRExportOptions.get_ExportOptionsEx()'



Any help on this issue would be appreciated.


Thanks,

John



Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Jan 07, 2015 at 04:45 PM

    Hi John

    This is a known issue documented in this KBA:

    2105311 - ExportToStream throws exception in SP 12 in Crystal Reports for Visual Studio

    - Ludek

    Senior Support Engineer AGS Product Support, Global Support Center Canada

    Follow us on Twitter

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 07, 2015 at 05:02 PM

    I just got an update from R&D on the issue. It is not good news;

    In a nutshell, export to memory stream was never supported. The Crystal Reports .NET API Guide states that the only return type is System.IO.Stream:

    Unfortunately, this will not be "fixed" or updated as investigation showed that this would cause other issues.

    - Ludek


    pastedImage_0.png (14.0 kB)
    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Ludek Uher

      I found out that if you build your app on x64 the export will work properly, but this still not an option to me to use only x64.

      is there any work around?

  • avatar image
    Former Member
    Jan 08, 2015 at 05:32 AM

    Hello Everyone,

           As a quick resolution what we did in our recent programs we created a extension method for the ReportDocument object

    so only you have to replace in your code

    ReportDocument cr = new ReportDocument()

    ....

    ..

    (MemoryStream)cr.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

    can be converted in to

    cr.ExportToMemoryStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

    yes from vs 2008 onward you can start use the extension methods

    a quick sample of extension code will look like

    public static class Extensions

        {

    public static MemoryStream ExportToMemoryStream(this ReportDocument cr, ExportFormatType reportformat)

            {

                Stream tempStream = cr.ExportToStream(reportformat);

                MemoryStream tempMemStream = new MemoryStream();

                tempStream.CopyTo(tempMemStream);

                tempStream.Close();

                return tempMemStream;

            }

    }

    "  !!!!Hope this helps at least as a quick resolution for the issue and " hoping that future sap will not add a method like this to make another issue

    Regards

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Dear John,

      Sorry for the late reply im still on the sp10 i did not upgrade my sp to sp12 let me test and will give you the feedback soon.