Our solution (after 2 years of struggle) for using Crystal Report Viewer XI with a dynamic XML data source, without requiring a full Crystal Developer install on each client machine (very pricey):
Attached is our Progress code for calling the Report Viewer. You may need to modify it considerably. There would be an associated .wrx, created by inserting as an OCX C:\Program Files (x86)\Business Objects\Common\3.5\crystalreportviewers115\ActiveXControls\CRViewer.dll [or the equivalent for your installation]
Hopefully this will help someone. We had a huge amount of help with this from Ionut Balas (balasionut@gmail.com) who is a Romanian freelancer who doesn't know much about Progress but is Crystal guru. He says that he is open to providing others with assistance.
Core of the viewer program is this:
/*------------------------------------------------------------------------------
Purpose: Take an .rpt, .xml, and .xsd file and display a Crystal report.
Notes:
------------------------------------------------------------------------------*/
/* already defined in definitions section:
/* com-handles to the various objects necessary to open a Crystal report */
define variable chApplication as com-handle no-undo.
define variable chViewer as com-handle no-undo.
define variable chReport as com-handle no-undo.
define variable chTable as com-handle no-undo.
*/
*/
define variable counter as integer no-undo.
define variable lv-data as character no-undo.
/* get the full path for the rpt and xml/xsd files */
file-info:filename = pv-report.
pv-report = file-info:full-pathname.
file-info:filename = pv-data.
pv-data = file-info:full-pathname.
/* set a string that indicates the location and names of the xml and xsd
files */
lv-data =
"Local XML File=" + pv-data + ";" +
"Local Schema File=" + entry(1,pv-data,".") + ".xsd".
/* create an instance of the Crystal runtime */
create "CrystalRuntime.Application" chApplication.
/* open a report in the Crystal runtime */
chReport = chApplication:OpenReport(pv-report,1).
/* get rid of any data that was saved with the report */
chReport:DiscardSavedData().
/* if this report has a table, then set its connection string and location */
if chReport:Database:Tables:Count > 0 then do:
/* set the connection string on the first table to the xml and xsd
files */
chReport:Database:Tables(1):ConnectBufferString = (lv-data).
/* loop through the tables in the report (this includes subtables),
setting each ones location (the location of the xml and xsd files) */
do counter = 1 to chReport:Database:Tables:Count:
/* get a com-handle to the current table */
chTable = chReport:Database:Tables(counter).
/* if the table uses an xml as a datasource, then set its table
location to the xml and xsd that was passed in */
if chTable:DecriptiveName = "XML" then
chTable:SetTableLocation(
chTable:Location, /* name of table */
"", /* not sure what this parameter is */
lv-data). /* the datasource connection string */
end. /* loop through tables */
end. /* report has a table */
/* read in records from the datasource to the report */
chReport:ReadRecords().
/* set some attributes on the Crystal report viewer, and then view the
report */
chViewer:DisplayTabs = false.
chViewer:ReportSource = chReport.
chViewer:ViewReport().
end procedure.
[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/crystalviewer.w.zip:550:0]