cancel
Showing results for 
Search instead for 
Did you mean: 

Exporting Crystal Reports to Excel in VS 2012

Former Member
0 Kudos

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:


(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



Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Ok, thanks Ludek. Hopefully there will be a fix in service pack 13.

Answers (2)

Answers (2)

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Vimal,

I just got a chance to test your code there now.

Unfortunately, I still get the same error on the line where it tries to export the report to a Stream:

'CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag CrystalDecisions.ReportAppServer.ReportDefModel.ISCRExportOptions.get_ExportOptionsEx()'

I'm using version 13.0.10.1385 of the developer dll's (Service Pack 12).

Are you using the same version?

I don't mind converting a Stream to MemoryStream if this is the workaround, but that isn't working either.

Any ideas?

Thanks,

John

Former Member
0 Kudos

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.

former_member183750
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hi Ludek,

We've been exporting crystal reports to a 'MemoryStream' for years in our web applications.

It worked in previous crystal report developer files (e.g. v12.0.2000.683, v10.5.0.1943).

Why would they take out something that worked in an older version?

Doesn't really make sense to be honest.

Is it best if I use v10.5.0.1943 of the CR dll's to continue to export reports to a memory stream?

Regards,

John

Former Member
0 Kudos

Hello John,

There had a long discussion regarding the same issue and we did not get any positive response from sap

We are still in hold of the upgrade of crystal report in production and cloud even in development pcs

For us it is very hard to recompile again old dlls to our clients as this will make somany issues

Dear Luke

, please ask the developers to revert the original code in next sp, many people are going to report the same issue as this was a complete convinent code we started early in. Net 1.1 and we never faced any issues related to that and suddenly!!!!

Regards

former_member183750
Active Contributor
0 Kudos

It is not possible to revert the code.

The modification that causes the issue, was done under the assumption that  the API was used as described in the API Guide. E.g.; the modification does not affect System.IO.Stream as this was always supported. It affects unsupported Memory.Stream, which was never supported. Reverting the code base will cause issues that the modification was meant to address in the 1st place.

I feel your pain, but R&D has spent a significant amount of time investigating the issue and it is their assessment that more changes will destabilize the product at best and make it unusable at worst.

- Ludek

Former Member
0 Kudos

Ludek - I'm confused. Is this the same issue as the thread: http://scn.sap.com/thread/3632979 Because if so, the last comment you make is that the developer's know about the issue and that it will be fixed in the next release - SP 13:

--------------------------------------------------------------------------

Hi Deana, My initial tests with SP 12 I could get it to create the file but it was always either 0 size or un-readable by Adobe Reader. I pinged the developers last night and we believe we know why it's failing now... It was an older Adapt that was propagated into SP 11 - ADAPT01320923 - Unable to export file larger than 300mb Only happens when exporting to System.IO.MemoryStream It’s OK with System.IO.Stream So I'll get this into the SP 13 required fixes and We should be able to fix it. SP 13 is tentatively due out end of January, but that just an estimate at this time... Thanks again Don -----------------------------------------------------------------------

Please advise.

Former Member
0 Kudos

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?