|
Report Application Server .NET SDK Developer Guide
|
|
To add a database field to a report
|
|
- Retrieve the database tables from the report, and get the first field from the first table.
|
Visual Basic
|
|
|
Dim field As ISCRField = rcd.DatabaseController.Database.Tables(0).DataFields(0)
|
|
C#
|
|
|
ISCRField field = rcd.DatabaseController.Database.Tables[0].DataFields[0];
|
- Create a new field object and set the FieldValueType and DataSource properties based on the first field retrieved.
|
Visual Basic
|
|
|
Dim fieldObject As FieldObject = New FieldObjectClass() fieldObject.FieldValueType = field.Type fieldObject.DataSourceName = field.FormulaForm
|
|
C#
|
|
|
FieldObject fieldObject = new FieldObjectClass(); fieldObject.FieldValueType = field.Type; fieldObject.DataSourceName = field.FormulaForm;
|
- Set formatting options for the FieldObject.
In this example the position of the field object is set.
|
Visual Basic
|
|
|
fieldObject.Left = 9400
|
|
C#
|
|
|
fieldObject.Left = 9400;
|
- Using the ReportDefController object, find the section of the report that the FieldObject will be added to
|
Visual Basic
|
|
|
Dim reportDef As ReportDefController2 = rcd.ReportDefController Dim sectionToAddTo As Section = reportDef.ReportDefinition.DetailArea.Sections(0)
|
|
C#
|
|
|
ReportDefController2 reportDef = rcd.ReportDefController; Section sectionToAddTo = reportDef.ReportDefinition.DetailArea.Sections[0];
|
- Add the FieldObject to a section in the report using the ReportDefController object.
|
Visual Basic
|
|
|
reportDef.ReportObjectController.Add(fieldObject, sectionToAddTo, 0)
|
|
C#
|
|
|
reportDef.ReportObjectController.Add(fieldObject, sectionToAddTo, 0);
|
This sample adds a single database field to the page header of a report.
|
Visual Basic
|
|
|
Private Sub AddDatabaseField(ByVal rcd As ISCDReportClientDocument) Dim field As ISCRField = rcd.DatabaseController.Database.Tables(0).DataFields(0) Dim fieldObject As FieldObject = New FieldObjectClass() fieldObject.FieldValueType = field.Type fieldObject.DataSourceName = field.FormulaForm fieldObject.Left = 9400 Dim reportDef As ReportDefController2 = rcd.ReportDefController Dim sectionToAddTo As Section = reportDef.ReportDefinition.DetailArea.Sections(0) reportDef.ReportObjectController.Add(fieldObject, sectionToAddTo, 0) End Sub
|
|
C#
|
|
|
private void AddDatabaseField(ISCDReportClientDocument rcd) { ISCRField field = rcd.DatabaseController.Database.Tables[0].DataFields[0]; FieldObject fieldObject = new FieldObjectClass(); fieldObject.FieldValueType = field.Type; fieldObject.DataSourceName = field.FormulaForm; fieldObject.Left = 9400; ReportDefController2 reportDef = rcd.ReportDefController; Section sectionToAddTo = reportDef.ReportDefinition.DetailArea.Sections[0]; reportDef.ReportObjectController.Add(fieldObject, sectionToAddTo, 0); }
|
This list includes the namespaces used by the sample code:
- CrystalDecisions.Enterprise
- CrystalDecisions.ReportAppServer.ClientDoc
- CrystalDecisions.ReportAppServer.DataDefModel
- CrystalDecisions.ReportAppServer.Controllers
- CrystalDecisions.ReportAppServer.ReportDefModel
© 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: iPhone web sites made easy