To modify a report object

This sample shows how to modify the height and width of a report object, set the background color, and change the border.
  1. Retrieve an instance of the ReportDefController object.
    ReportDefController reportDefController = rcd.getReportDefController();
  2. Retrieve an instance of the ReportObjectController object.
    ReportObjectController reportObjectController = reportDefController.getReportObjectController();
  3. 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);
  4. Create a copy of the report object.
    TextObject newObject = (TextObject) object.clone(true);
  5. Set the height and width of the new report object.
    newObject.setHeight(3000);
    newObject.setWidth(5000);
  6. 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);
  7. 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