Crystal Reports
-
Hi, A quick question with regards the above: Can one use Crystal Reports in Visual C++? And if so how does one go about doing that? Thanks Regards Rui
-
Hi, A quick question with regards the above: Can one use Crystal Reports in Visual C++? And if so how does one go about doing that? Thanks Regards Rui
Yes you can do that. Via COM it is possible to open reports, show them in a window (in a Crystal Reports Viewer ActiveX control), and perform all kinds of actions on it (print, mail, ...). It is even possible to show the embeddable designer, and let you users design their own reports; within your application (although you need a separate license for this). Normally the data for your report will come from a database (that's easy), but it's even possible to tell Crystal Reports that the data comes from within your application. However be careful, since CR 9.0 does not support the same functionality as CR 8.5. If you want to do this I suggest to go to CR 9.0 directly. When you only want to show the report in your application, you don't have to pay any runtime royalty to CR (you can ship a free CR View-Only Runtime). However, if you want to create or modify reports from within your application, or let the user create or modify reports, you need a special RCAPI (Report Creation (or was it Component) API) license. This license is per named user, and costs about the same as a full Crystal Reports. This license and the Design-Time RunTime is mandatory ! simply installing Crystal Reports won't do the job. Best way to get more information is to look at the crystal reports site, especially the developer zone (http://www.crystaldecisions.com/products/dev_zone[^]). Enjoy life, this is not a rehearsal !!!
-
Yes you can do that. Via COM it is possible to open reports, show them in a window (in a Crystal Reports Viewer ActiveX control), and perform all kinds of actions on it (print, mail, ...). It is even possible to show the embeddable designer, and let you users design their own reports; within your application (although you need a separate license for this). Normally the data for your report will come from a database (that's easy), but it's even possible to tell Crystal Reports that the data comes from within your application. However be careful, since CR 9.0 does not support the same functionality as CR 8.5. If you want to do this I suggest to go to CR 9.0 directly. When you only want to show the report in your application, you don't have to pay any runtime royalty to CR (you can ship a free CR View-Only Runtime). However, if you want to create or modify reports from within your application, or let the user create or modify reports, you need a special RCAPI (Report Creation (or was it Component) API) license. This license is per named user, and costs about the same as a full Crystal Reports. This license and the Design-Time RunTime is mandatory ! simply installing Crystal Reports won't do the job. Best way to get more information is to look at the crystal reports site, especially the developer zone (http://www.crystaldecisions.com/products/dev_zone[^]). Enjoy life, this is not a rehearsal !!!
Hi Patje, THank you very much for the information. May I ask you something else: The Crystal Reports that comes with Studio .Net, how does this fit in with what you are saying? I notice that one can create a crystal report item for a C++ application, would this be the report that is called by the Crystal Reports Viewer ActiveX control? Thanks Regards
-
Hi Patje, THank you very much for the information. May I ask you something else: The Crystal Reports that comes with Studio .Net, how does this fit in with what you are saying? I notice that one can create a crystal report item for a C++ application, would this be the report that is called by the Crystal Reports Viewer ActiveX control? Thanks Regards
I don't know anything about the CR that comes with VS.Net, but I assume that it's a kind 8.5.Net version, not the brand new CR 9.0. We are using the CR ActiveX control by using the "AtlAxWin" control (part of ATL 3.0) and passing it
- "CrystalReport.EmbeddableCrystalReportsDesignerCtrl.8.5" for the embeddable designer
- "CRViewer.CRViewer.8.0" for the ActiveX viewer
Then use ATL::AtlAxGetControl to get the IUnknown interface of the ActiveX control hosted in the AtlAxWin control.
ATL::AtlAxGetControl (NativeWin, &UnknownInterface);
Then use IUnknownInterface->QueryInterface to get the interface to the CRVIEWERLib::ICrystalReportViewer4Ptr.hr = UnknownInterface->QueryInterface (__uuidof(CRVIEWERLib::ICrystalReportViewer4),(void **)&CrystalReportViewer);
or for the designer:hr = UnknownInterface->QueryInterface (__uuidof(CRDESIGNERCTRLLib::ICRDesignerCtrl),(void **)&CrystalReportDesigner);
Then simply useCrystalReportViewer->ReportSource = MyReport
to set the report in the viewer (similar for the designer). Don't forget to import the necessary type libraries:#import "CRAXDDRT.tlb" // The Crystal Reports designer run-time #import "CRAXDRT.tlb" // The Crystal Reports non-designer run-time #import "crviewer.tlb" // The Crystal Reports viewer component #import "CRDesignerCtrl.tlb" // The Crystal Reports designer module
Also take a look at the generated .tli and .tlh files (by the #import). They're also very interesting if you want to know some of the more technical details. Hope this helps (this was one of my first C++/COM projects, a real C++/COM guru might write this maybe a bit more efficient). Enjoy life, this is not a rehearsal !!!