This sample shows how to modify the height and
width of a report object, set the background color, and change the border.
Retrieve an instance of the
ReportDefController object.
ReportDefController reportDefController = rcd.getReportDefController();
Retrieve an instance of the
ReportObjectController object.
ReportObjectController reportObjectController = reportDefController.getReportObjectController();
Find the report object.
This example finds the first
TextObject
object in the report.
ReportObjects reportObjects = reportObjectController.getReportObjectsByKind(ReportObjectKind.text);
TextObject object = (TextObject)reportObjects.get(0);
Create a copy of the report object.
TextObject newObject = (TextObject) object.clone(true);
Set the height and width of the new
report object.
newObject.setHeight(3000);
newObject.setWidth(5000);
Set the border properties of the
object.
This sample changes the
background color to yellow, and changes the border to be a double line.
Border border = newObject.getBorder();
border.setBackgroundColor(java.awt.Color.YELLOW);
border.setTopLineStyle(LineStyle.doubleLine);
border.setBottomLineStyle(LineStyle.doubleLine);
border.setLeftLineStyle(LineStyle.doubleLine);
border.setRightLineStyle(LineStyle.doubleLine);
newObject.setBorder(border);
Use the
ReportObjectController.modify
method to modify the original object based on the changes you have made in the
copy.
reportObjectController.modify(object, newObject);
Example:
This sample changes the size, background color, and
border of a text object.
void modifyReportObject (ReportClientDocument rcd) throws ReportSDKException
{
ReportDefController reportDefController = rcd.getReportDefController();
ReportObjectController reportObjectController = reportDefController.getReportObjectController();
ReportObjects reportObjects = reportObjectController.getReportObjectsByKind(ReportObjectKind.text);
TextObject object = (TextObject)reportObjects.get(0);
TextObject newObject = (TextObject) object.clone(true);
newObject.setHeight(3000);
newObject.setWidth(5000);
IBorder border = newObject.getBorder();
border.setBackgroundColor(java.awt.Color.YELLOW);
border.setTopLineStyle(LineStyle.doubleLine);
border.setBottomLineStyle(LineStyle.doubleLine);
border.setLeftLineStyle(LineStyle.doubleLine);
border.setRightLineStyle(LineStyle.doubleLine);
newObject.setBorder(border);
reportObjectController.modify(object, newObject);
}This list includes the classes used by the sample
code:
com.crystaldecisions.sdk.occa.report.application.ReportClientDocument
com.crystaldecisions.sdk.occa.report.application.ReportDefController
com.crystaldecisions.sdk.occa.report.application.ReportObjectController
com.crystaldecisions.sdk.occa.report.definition.IBorder
com.crystaldecisions.sdk.occa.report.definition.LineStyle
com.crystaldecisions.sdk.occa.report.definition.ReportObject
com.crystaldecisions.sdk.occa.report.definition.ReportObjects
com.crystaldecisions.sdk.occa.report.definition.TextObject
com.crystaldecisions.sdk.occa.report.lib.ReportObjectKind
com.crystaldecisions.sdk.occa.report.lib.ReportSDKException