Developed by Business Object, Crystal Report has long been widely vowed as a leading product for generating different kind of reports. .Net framework has full API support for developing Crystal Report. This artical will walk through the main features of creating Crystal reports with Asp.Net.
The development API
List 1 demonstrates the mostly used namespaces:
[list 1: Namespaces]
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Web;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Shared;
These namespaces are accomodated within the following assemblies:
CrystalDescisions.CrystalReports.Engin.dll
CrystalDecisions.ReportSource.dll
CrystalDecisions.Shared.dll
CrystalDecisions.Web.dll
The process
CrystalReportViewer rptViewer = new CrystalReportViewer();
ReportDocument repDoc = new ReportDocument();
// show report on a page
string rptFilePath = "c:\reports\xxx.rpt";
rptDoc.Load(rptFilePath);
rptViewer.ReportSource = rptDoc;
Page.Form.Controls.Add(rptViewer);
Export Report
If we need just show the report onto a web page, CrystalReportViewer, a web user control, is just doing that. if we need to export report to a file, in PDF, Excel or other supported format, use Export method of ReportClass:
ReportClass.Export();
ReportClass rpt = new ReportClass();
rpt.RecordSet = recordset;
rpt.GroupOn = string[]{columns};
rpt.SubTotal = string[]{columns}
Deployment
When install Visual Studio, Crystal Report assemblies are installed into the GAC. You also can manually install it from:
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages\CrystalReports\CRRedist2005_x86.msi
within VS2005 for example.
When deploy to production, instead of install Visual studio, you can download and install Crystal Report's redistribution package from Business Object.
No comments:
Post a Comment