To modify a report object

Parent Previous Next

 

Report Application Server .NET SDK Developer Guide

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.

Visual Basic

Dim reportDefController As ReportDefController2 = rcd.ReportDefController

C#

ReportDefController2 reportDefController = rcd.ReportDefController;

  1. Retrieve an instance of the ReportObjectController object.

Visual Basic

Dim reportObjectController As ReportObjectController = rcd.ReportDefController.ReportObjectController

C#

ReportObjectController reportObjectController = rcd.ReportDefController.ReportObjectController;

  1. Find the report object.

This example finds the first TextObject object in the report.

Visual Basic

Dim reportObjects As ReportObjects = reportObjectController.GetReportObjectsByKind(CrReportObjectKindEnum.crReportObjectKindText)
Dim textObject As TextObject = DirectCast(reportObjects(0), TextObject)

C#

ReportObjects reportObjects = reportObjectController.GetReportObjectsByKind(CrReportObjectKindEnum.crReportObjectKindText);
TextObject textObject = (TextObject)reportObjects[0];

  1. Create a copy of the report object.

Visual Basic

Dim newObject As TextObject = DirectCast(textObject.Clone(True), TextObject)

C#

TextObject newObject = (TextObject)textObject.Clone(true);

  1. Set the height and width of the new report object.

Visual Basic

newObject.Height = 3000
newObject.Width = 3000

C#

newObject.Height = 3000;
newObject.Width = 3000;

  1. Set the border properties of the object.

This sample changes the background color to yellow, and changes the border to be a double line.

Visual Basic

Dim border As ISCRBorder = newObject.Border
border.BackgroundColor = UInteger.Parse(ColorTranslator.ToOle(Color.Yellow).ToString())
border.TopLineStyle = CrLineStyleEnum.crLineStyleDouble
border.BottomLineStyle = CrLineStyleEnum.crLineStyleDouble
border.LeftLineStyle = CrLineStyleEnum.crLineStyleDouble
border.RightLineStyle = CrLineStyleEnum.crLineStyleDouble
newObject.Border = DirectCast(border, Border)

C#

ISCRBorder border = newObject.Border;
border.BackgroundColor = uint.Parse(ColorTranslator.ToOle(Color.Yellow).ToString());
border.TopLineStyle = CrLineStyleEnum.crLineStyleDouble;
border.BottomLineStyle = CrLineStyleEnum.crLineStyleDouble;
border.LeftLineStyle = CrLineStyleEnum.crLineStyleDouble;
border.RightLineStyle = CrLineStyleEnum.crLineStyleDouble;
newObject.Border = (Border)border;

  1. Use the ReportObjectController.Modify method to modify the original object based on the changes you have made in the copy.

Visual Basic

reportObjectController.Modify(textObject, newObject)

C#

reportObjectController.Modify(textObject, newObject);

This sample changes the size, background color, and border of a text object.

Visual Basic

Private Sub ModifyObject(ByVal rcd As ISCDReportClientDocument)
 Dim reportDefController As ReportDefController2 = rcd.ReportDefController
 Dim reportObjectController As ReportObjectController = rcd.ReportDefController.ReportObjectController
 Dim reportObjects As ReportObjects = reportObjectController.GetReportObjectsByKind(CrReportObjectKindEnum.crReportObjectKindText)
 Dim textObject As TextObject = DirectCast(reportObjects(0), TextObject)
 Dim newObject As TextObject = DirectCast(textObject.Clone(True), TextObject)
 newObject.Height = 3000
 newObject.Width = 3000
 Dim border As ISCRBorder = newObject.Border
 border.BackgroundColor = UInteger.Parse(ColorTranslator.ToOle(Color.Yellow).ToString())
 border.TopLineStyle = CrLineStyleEnum.crLineStyleDouble
 border.BottomLineStyle = CrLineStyleEnum.crLineStyleDouble
 border.LeftLineStyle = CrLineStyleEnum.crLineStyleDouble
 border.RightLineStyle = CrLineStyleEnum.crLineStyleDouble
 newObject.Border = DirectCast(border, Border)
 reportObjectController.Modify(textObject, newObject)
End Sub

C#

private void ModifyObject(ISCDReportClientDocument rcd)
{
 ReportDefController2 reportDefController = rcd.ReportDefController;
 ReportObjectController reportObjectController = rcd.ReportDefController.ReportObjectController;
 ReportObjects reportObjects = reportObjectController.GetReportObjectsByKind(CrReportObjectKindEnum.crReportObjectKindText);
 TextObject textObject = (TextObject)reportObjects[0];
 TextObject newObject = (TextObject)textObject.Clone(true);
 newObject.Height = 3000;
 newObject.Width = 3000;
 ISCRBorder border = newObject.Border;
 border.BackgroundColor = uint.Parse(ColorTranslator.ToOle(Color.Yellow).ToString());
 border.TopLineStyle = CrLineStyleEnum.crLineStyleDouble;
 border.BottomLineStyle = CrLineStyleEnum.crLineStyleDouble;
 border.LeftLineStyle = CrLineStyleEnum.crLineStyleDouble;
 border.RightLineStyle = CrLineStyleEnum.crLineStyleDouble;
 newObject.Border = (Border)border;
 reportObjectController.Modify(textObject, newObject);
}

This list includes the namespaces used by the sample code:

© 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: Full-featured Kindle eBooks generator