|
Report Application Server .NET SDK Developer Guide
|
|
To open a report and access the ReportClientDocument class in-process
|
|
The Crystal Reports .NET SDK allows you to access the ReportClientDocument object model within a single-tier .NET application environment. This API contains advanced report modification functionality.
In-process means that the deployment package for the application requires only the .NET assemblies, without a RAS server. To access the ReportClientDocument class in-process, open a report using the CrystalDecisions.CrystalReports.Engine.ReportDocument class, and then call its ReportClientDocument property. The report can then be modified using the ReportClientDocument object model. After making changes to the report, pass the ReportDocument object to the report source of the CrystalReportViewer control for viewing or before exporting the report.
The ReportDocument and ReportClientDocument object models can be used interchangeably to manipulate a report. No exceptions will be thrown if you use first modify a report with one object model and then use the other object model to further manipulate the report. For more information about the Crystal Reports .NET SDK, see the Crystal Reports .NET SDK Developer Guide.
|
Note
|
|
If you use the ReportClientDocument class in-process, you lose the performance and stability benefits of a server-oriented, out-process system. To gain these benefits, use the API in conjunction with a RAS server in a SAP BusinessObjects Enterprise environment.
|
- Set the file path of the report you want to open.
|
Visual Basic
|
|
|
Dim mySampleReportPath As String = "C:\oledbReport.rpt"
|
|
C#
|
|
|
string sampleReportPath = @"C:\oledbReport.rpt";
|
- Create a new ReportDocument object and load the report.
|
Note
|
|
The ReportDocument class is part of the CrystalDecisions.CrystalReports.Engine namespace.
|
|
Visual Basic
|
|
|
Dim rd As New ReportDocument rd.Load(mySampleReportPath)
|
|
C#
|
|
|
ReportDocument rd = new ReportDocument(); rd.Load(sampleReportPath);
|
- Use the ReportClientDocument property of the ReportDocument class to retrieve a ReportClientDocument object that represents the report.
|
Visual Basic
|
|
|
ISCDReportClientDocument rcd = rd.ReportClientDocument
|
|
C#
|
|
|
ISCDReportClientDocument rcd = rd.ReportClientDocument;
|
- Use the ReportClientDocument object to modify the report.
|
Note
|
|
You can use the ReportClientDocument object model to perform a wide variety of advanced report modification tasks. This particular example assumes that you have a report called oledbReport.rpt and changes the database connection for a table called "tableName" to an OLEDB data source.
|
|
Visual Basic
|
|
|
Dim newConnectionInfo As New ConnectionInfoClass() Dim currentConnectionInfo As New ConnectionInfoClass() Dim logonAttributes As New PropertyBagClass() Dim connectionAttributes As New PropertyBagClass() logonAttributes.Add("Data Source", "DatabaseServer\DatabaseInstance") connectionAttributes.Add("Database DLL", "crdb_ado.dll") connectionAttributes.Add("QE_DatabaseType", "OLE DB (ADO)") connectionAttributes.Add("QE_LogonProperties", logonAttributes) connectionAttributes.Add("QE_ServerDescription", "Enter description of your server") connectionAttributes.Add("QE_SQLDB", True) connectionAttributes.Add("Server Name", "DatabaseInstanceName") connectionAttributes.Add("SSO Enabled", False) newConnectionInfo.Attributes = connectionAttributes newConnectionInfo.UserName = "userName" newConnectionInfo.Password = "password" newConnectionInfo.Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE rcd.DatabaseController.ModifyTableConnectionInfo("tableName", newConnectionInfo)
|
|
C#
|
|
|
ConnectionInfo newConnectionInfo = new ConnectionInfoClass(); ConnectionInfo currentConnectionInfo = new ConnectionInfoClass(); PropertyBag logonAttributes = new PropertyBagClass(); PropertyBag connectionAttributes = new PropertyBagClass(); logonAttributes.Add("Data Source", "DatabaseServer\\DatabaseInstance"); connectionAttributes.Add("Database DLL", "crdb_ado.dll"); connectionAttributes.Add("QE_DatabaseType","OLE DB (ADO)"); connectionAttributes.Add("QE_LogonProperties", logonAttributes); connectionAttributes.Add("QE_ServerDescription", "Enter description of your server"); connectionAttributes.Add("QE_SQLDB", true); connectionAttributes.Add("Server Name","DatabaseServer\\DatabaseInstance"); connectionAttributes.Add("SSO Enabled", false); newConnectionInfo.Attributes = connectionAttributes; newConnectionInfo.UserName = "userName"; newConnectionInfo.Password = "password"; newConnectionInfo.Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE; rcd.DatabaseController.ModifyTableConnectionInfo("tableName", newConnectionInfo);
|
- Render the report with the CrystalReportViewer class.
The report source for the viewer is set using the ReportDocument object, which reflects the changes you made to the report using the ReportClientDocument object.
|
Visual Basic
|
|
|
crystalReportViewer.ReportSource = rd
|
|
C#
|
|
|
crystalReportViewer.ReportSource = rd;
|
The following code opens a report in-process using the ReportDocument.ReportClientDocument property, modifies a database table connection using the ReportClientDocument object model, and renders the changes to the user with the CrystalReportViewer class.
|
Visual Basic
|
|
|
Private Sub OpenReportInProc(ByVal crystalReportViewer As CrystalReportViewer) Dim mySampleReportPath As String = "C:\oledbReport.rpt" Dim rd As New ReportDocument rd.Load(mySampleReportPath) ISCDReportClientDocument rcd = rd.ReportClientDocument Dim newConnectionInfo As New ConnectionInfoClass() Dim currentConnectionInfo As New ConnectionInfoClass() Dim logonAttributes As New PropertyBagClass() Dim connectionAttributes As New PropertyBagClass() logonAttributes.Add("Data Source", "DatabaseServer\DatabaseInstance") connectionAttributes.Add("Database DLL", "crdb_ado.dll") connectionAttributes.Add("QE_DatabaseType", "OLE DB (ADO)") connectionAttributes.Add("QE_LogonProperties", logonAttributes) connectionAttributes.Add("QE_ServerDescription", "Enter description of your server") connectionAttributes.Add("QE_SQLDB", True) connectionAttributes.Add("Server Name", "DatabaseInstanceName") connectionAttributes.Add("SSO Enabled", False) newConnectionInfo.Attributes = connectionAttributes newConnectionInfo.UserName = "userName" newConnectionInfo.Password = "password" newConnectionInfo.Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE rcd.DatabaseController.ModifyTableConnectionInfo("tableName", newConnectionInfo) crystalReportViewer.ReportSource = rd End Sub
|
|
C#
|
|
|
private void OpenReportInProc(CrystalReportViewer crystalReportViewer) { string sampleReportPath = @"C:\oledbReport.rpt"; ReportDocument rd = new ReportDocument(); rd.Load(sampleReportPath); ISCDReportClientDocument rcd = rd.ReportClientDocument; ConnectionInfo newConnectionInfo = new ConnectionInfoClass(); ConnectionInfo currentConnectionInfo = new ConnectionInfoClass(); PropertyBag logonAttributes = new PropertyBagClass(); PropertyBag connectionAttributes = new PropertyBagClass(); logonAttributes.Add("Data Source", "DatabaseServer\\DatabaseInstance"); connectionAttributes.Add("Database DLL", "crdb_ado.dll"); connectionAttributes.Add("QE_DatabaseType","OLE DB (ADO)"); connectionAttributes.Add("QE_LogonProperties", logonAttributes); connectionAttributes.Add("QE_ServerDescription", "Enter description of your server"); connectionAttributes.Add("QE_SQLDB", true); connectionAttributes.Add("Server Name","DatabaseServer\\DatabaseInstance"); connectionAttributes.Add("SSO Enabled", false); newConnectionInfo.Attributes = connectionAttributes; newConnectionInfo.UserName = "userName"; newConnectionInfo.Password = "password"; newConnectionInfo.Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE; rcd.DatabaseController.ModifyTableConnectionInfo("tableName", newConnectionInfo); crystalReportViewer.ReportSource = rd; }
|
This list includes the namespaces used by the sample code:
- CrystalDecisions.CrystalReports.Engine.ReportDocument
- CrystalDecisions.ReportAppServer.ClientDoc
© 2021 SAP AG. All rights reserved.
http://www.sap.com/sapbusinessobjects/
Support services
http://service.sap.com/bosap-support/
Created with the Personal Edition of HelpNDoc: Easily create iPhone documentation