Skip to Content
0

Using Crystal Reports for Visual Studio with Reports Developed Using Crystal Reports 2013

Dec 05, 2016 at 11:53 PM

108

avatar image
P R

Hi,

I have many reports that have been developed using Crystal Reports 2013. I have a need to export hundreds of different instances to PDF format, so I downloaded and installed Crystal Reports for Visual Studio (Support Pack 18).

I wrote code to load an existing report that was developed with Crystal Reports 2013 and export it to PDF. However, one of the charts in the PDF export had extra blank items in the legend. There were 4 legend items that were defined in the "in specified order" menu in the Chart Expert and 4 blank legend items (for a total of 8).

That specific chart is in its own sub-report. I have other charts that have items defined using the "in specified order" menu in other sub-reports in the same report and they aren't displaying this way when I export to PDF.

The interesting thing is that the chart displays correctly if I export one instance of the report to PDF from within Crystal Reports 2013. The problem, though, is that it's not reasonably feasible for me to use Crystal Reports 2013 to export the hundreds of different instances to PDF, hence the desire to automate the process.

I chatted with an SAP representative that said the Crystal Reports for Visual Studio shouldn't be used with other SAP products, including Crystal Reports 2013. If that's the case, how can I use .NET to work with existing reports that were developed with Crystal Reports 2013?

Thanks.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Don Williams
Dec 07, 2016 at 09:30 PM
0

No, you need to log onto each subreport also. We used to propagate the connection info but no longer because the main reason for using subreports is because you have a different connection.

Try it and see if you still get the missing data

Share
10 |10000 characters needed characters left characters exceeded
Don Williams
Dec 05, 2016 at 11:57 PM
0

Hi PR,

Are you setting the log on info for each subreport?

What happens if you export to RPT format and then export that to PDF? Has saved data and should not need log on info then.

Is it possible for you to send me the report with saved data? I'll test it.

Unfortunately this system will no longer allow RPT's to be attached, even after renaming them so you need to provide a link to FTP site to share it.

Don

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Don,

I'm not setting the log on info for each sub-report in my application. I'm using the following code to load the report:

ReportDocument crReport = new ReportDocument();
crReport.Load(@"C:\Crystal Reports\Development\" + reportName + ".rpt");

if (crReport.IsLoaded)
    Console.WriteLine("The report is loaded.");
else
    Console.WriteLine("The report failed to load.");

Console.WriteLine("Establishing report database connection.");

crReport.SetDatabaseLogon(uid, password);

The code above appears to be working correctly since the report loads, it runs for parameters that I'm iterating over, and all the other sub-reports in the report generate successfully. Even though the chart on one of the sub-reports does not appear to be rendering correctly, the sub-report still loads and the data displayed on the chart is correct...there are just four extra blank legend items.

If I run my application and export to RPT instead of PDF, then manually export to PDF from the exported RPT file, the same issue still occurs. The same chart in the same sub-report has four extra blank legend items. If I open the original RPT and manually export to PDF, the four extra blank legend items do not appear.

I have re-created the chart multiple times on the original RPT and the issue persists. I have tried toggling the Chart Expert | Options | Auto-arrange setting and have tried right-clicking the chart and choosing Auto-Arrange Chart to no avail.

Unfortunately, I don't have access to an FTP site, so I won't be able to share the report with you. I took a screen shot of the PDF output and modified it slightly to redact confidential data (please note that the legend text is fake text I added to the screen shot, not a value that I used in the Crystal Report). I've attached the file for you. You'll see in the file that there are four extra blank legend items (I guess, technically, there are four extra blank items in the chart too since the bars on the original report are wider and a different color).

I did some additional testing on the chart and got some interesting results. The original chart works the same regardless of the changes, but when exported to PDF from my application (or exported to RPT and manual PDF export) things are behaving strangely. The bar chart has On Change Of set to two fields. One contains a year and the other contains a two-digit code, one of which is a symbol that I'm discarding when I use the Specified Order option (using Discard all others). If I leave the code in its original state and export with my application, it looks like it should when I export. The same thing happens if I change each of the four codes in Specified Order to be Item 1, Item 2, Item 3, Item 4, respectively. However, if I change the code in Specified Order to something that's a little longer, like Banana, Motorcycle, Umbrella, Turnpike, there are still blank legend items, but Banana shows up first, followed by three blanks, then Motorcycle, Umbrella, and Turnpike. To further test, I changed Discard all others to Leave in their own groups, but that only caused the chart to display the symbol that I wanted to discard along with the four blank legend items.

As a final shot in the dark test, I pulled in another description column from the database that's related to the code and used it in the On Change Of instead of the code. I specified the order and set the values to the same that I was using for the code. When I exported to PDF with my application, the items display correctly with no extra legend items. So, while I could conceivably use the description, it does go against how we typically pull in data in reports and I'm baffled as to why the description would work, but the code wouldn't when they're both being modified using Specified Order.

One question from my original post that you didn't answer that I'd like answered if you know it is whether it's acceptable for me to use Crystal Reports for Visual Studio the way I'm using it or not. If not, is there an alternative that would allow me to programmatically load a report developed separate from Visual Studio in Crystal Reports and export many instances to PDF?

Thanks.

0
Don Williams
Dec 07, 2016 at 04:28 PM
0

Hi PR,

You should still set logon info for each subreport, I believe the app is propagating the connection info to the subreports. I think likely because you are using ODBC and it tends to piggy back on the HDBC handle ODBC generates.

In any event you should set location for each, search for KBA 2281780, it has a parameter test app I wrote and can show you how to search for subreports and set the log on info for each.

Do you have No Printer checked on? If so uncheck it and use a real printer and also check on Dissociate so it removes the dependency on that printer and CR will use the printer "family" when formatting.

Yes CR for VS should work with all versions of CR Designer 2011 and above.

Without the report with saved data it's hard to say what the cause is.

Don

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Don,

No Printer is not checked on the main report or any of the sub-reports.

I'm using ODBC and, in my code, I did a quick check to iterate over the tables in the main report and all of the sub-reports. When I use the Table.TestConnectivity method for each table, all of them return True. If they are all connecting, is that not an indication that the sub-reports are being logged on to? I realize it's not explicit, but it still appears to be successful.

Thanks.

0