View Single Post
  #3 (permalink)  
Old 08-07-2007, 09:57 AM
SWFKit SWFKit is offline
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:Crystal Reports with SWFkit

Yes, you can use crystal reports in swfkit. But you must first apply the following patch for swfkit pro before you can do that, because the current version of swfkit pro cannot handle IUnknown interface properly.

http://www.swfkit.com/download/swfkit/propatch.zip

To apply the patch, you must unpack the downloaded zip file into the data sub folder of the directory that swfkit pro has been installed into. The typical path is c:\program files\swfkit pro 3\data

To use crystal reports in swfkit, please follow the following steps

1) create a crystal report by using the report designer

2) embed the crystal report viewer acitvex control in your main movie, or a form.

Code:
// first creates a crystal report viewer in the main movie
var viewer = createControl("CRViewer9.CRViewer", 0, 0, 800, 540);
3) create a crystal report object, and set data source for it
Code:
// creates a crystal report application object and opens the report template
var rapp = new ActiveXObject("CrystalRuntime.Application");
var report = rapp.openReport(getAdditionalFile("Report1.rpt"));

// prepares data source for the crystal report object
var conn_string = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + getAdditionalFile("student.mdb");
var conn = new ActiveXObject("ADODB.Connection");
conn.open(conn_string);

var record = new ActiveXObject("ADODB.Recordset");
record.Open("select id,name,age,sex,score from student", conn, 1, 2);

// sets data source for the crystal report
report.database.setDataSource(record);
report.readRecords();
4) preview the report in the report viewer
Code:
report.reportTitle = "My sample report";

// previews the crystal report
viewer.activex.reportSource = report;
viewer.activex.displayToolbar = false;
viewer.activex.displayGroupTree = false;
viewer.activex.viewReport();
5) distribute your project
You must distribute the crystal report viewer activex control (crviewer9.dll) and the crtstal report runtime activex component(craxdrt9.dll) with your final exe file. As the two dlls are activex components, you must register them in your exe file. For more details about activex registering, please read the following tutorial
http://www.swfkit.com/swfkit/doc/manual/node28.html

The following is the sample for using Crystal reports in swfkit. Before you can try it, you must have crsystal report 9 or above installed, as it does not include the crystal report runtime dlls.
http://www.swfkit.com/swfkit/samples...ort_sample.zip
Reply With Quote