|
Report Application Server .NET SDK Developer Guide
|
|
To add a text object to a report
|
|
Adding a text object to a report lets you create custom headings or to display information that is not included in the report data. A text object is a collection of paragraph objects, and each paragraph object is a collection of paragraph elements. Paragraphs and paragraph elements are customizable, giving you control over how your text object appears in the report.
- Create a new ParagraphTextElement object, and then set the Text and Kind properties.
Replace My text with your paragraph text.
|
Visual Basic
|
|
|
Dim paragraphTextElement As ISCRParagraphTextElement = New ParagraphTextElementClass() paragraphTextElement.Text = "My text." paragraphTextElement.Kind = CrParagraphElementKindEnum.crParagraphElementKindText
|
|
C#
|
|
|
ISCRParagraphTextElement paragraphTextElement = new ParagraphTextElementClass(); paragraphTextElement.Text = "My text"; paragraphTextElement.Kind = CrParagraphElementKindEnum.crParagraphElementKindText;
|
- Add the ParagraphTextElement object to a new ParagraphElements object collection.
|
Visual Basic
|
|
|
Dim paragraphElements As ParagraphElements = New ParagraphElementsClass() paragraphElements.Add(paragraphTextElement)
|
|
C#
|
|
|
ParagraphElements paragraphElements = new ParagraphElementsClass(); paragraphElements.Add(paragraphTextElement);
|
- Add the ParagraphElements object collection to a new Paragraphobject.
|
Visual Basic
|
|
|
Dim paragraph As Paragraph = New ParagraphClass() paragraph.ParagraphElements = paragraphElements
|
|
C#
|
|
|
Paragraph paragraph = new ParagraphClass(); paragraph.ParagraphElements = paragraphElements;
|
- Add the Paragraph object to a new Paragraphs object collection.
|
Visual Basic
|
|
|
Dim paragraphs As Paragraphs = New ParagraphsClass() paragraphs.Add(paragraph)
|
|
C#
|
|
|
Paragraphs paragraphs = new ParagraphsClass(); paragraphs.Add(paragraph);
|
- Add the Paragraphs object collection to a new TextObject object and set the properties of the text object.
In this sample the position and the width of the text object are set.
|
Visual Basic
|
|
|
Dim textObject As ISCRTextObject = New TextObjectClass() textObject.Paragraphs = paragraphs textObject.Left = 1440 textObject.Width = 4320
|
|
C#
|
|
|
ISCRTextObject textObject = new TextObjectClass(); textObject.Paragraphs = paragraphs; textObject.Left = 1440; textObject.Width = 4320;
|
- Use the ReportDefController object to add the text object to the report.
In this sample the text object is added to the report header.
|
Visual Basic
|
|
|
Dim reportDef As ReportDefController2 = rcd.ReportDefController Dim sectionToAddTo As Section = reportDef.ReportDefinition.ReportHeaderArea.Sections(0) reportDef.ReportObjectController.Add(textObject, sectionToAddTo, 0)
|
|
C#
|
|
|
ReportDefController2 reportDef = rcd.ReportDefController; Section sectionToAddTo = reportDef.ReportDefinition.ReportHeaderArea.Sections[0]; reportDef.ReportObjectController.Add(textObject, sectionToAddTo, 0);
|
This sample adds a text object to a report.
|
Visual Basic
|
|
|
Private Sub AddTextObject(ByVal rcd As ISCDReportClientDocument) Dim paragraphTextElement As ISCRParagraphTextElement = New ParagraphTextElementClass() paragraphTextElement.Text = "My text." paragraphTextElement.Kind = CrParagraphElementKindEnum.crParagraphElementKindText Dim paragraphElements As ParagraphElements = New ParagraphElementsClass() paragraphElements.Add(paragraphTextElement) Dim paragraph As Paragraph = New ParagraphClass() paragraph.ParagraphElements = paragraphElements Dim paragraphs As Paragraphs = New ParagraphsClass() paragraphs.Add(paragraph) Dim textObject As ISCRTextObject = New TextObjectClass() textObject.Paragraphs = paragraphs textObject.Left = 1440 textObject.Width = 4320 Dim reportDef As ReportDefController2 = rcd.ReportDefController Dim sectionToAddTo As Section = reportDef.ReportDefinition.ReportHeaderArea.Sections(0) reportDef.ReportObjectController.Add(textObject, sectionToAddTo, 0) End Sub
|
|
C#
|
|
|
private void AddTextObject(ISCDReportClientDocument rcd) { ISCRParagraphTextElement paragraphTextElement = new ParagraphTextElementClass(); paragraphTextElement.Text = "My text."; paragraphTextElement.Kind = CrParagraphElementKindEnum.crParagraphElementKindText; ParagraphElements paragraphElements = new ParagraphElementsClass(); paragraphElements.Add(paragraphTextElement); Paragraph paragraph = new ParagraphClass(); paragraph.ParagraphElements = paragraphElements; Paragraphs paragraphs = new ParagraphsClass(); paragraphs.Add(paragraph); ISCRTextObject textObject = new TextObjectClass(); textObject.Paragraphs = paragraphs; textObject.Left = 1440; textObject.Width = 4320; ReportDefController2 reportDef = rcd.ReportDefController; Section sectionToAddTo = reportDef.ReportDefinition.ReportHeaderArea.Sections[0]; reportDef.ReportObjectController.Add(textObject, sectionToAddTo, 0); }
|
This list includes the namespaces used by the sample code:
- CrystalDecisions.Enterprise
- CrystalDecisions.ReportAppServer.ClientDoc
- 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: Free EBook and documentation generator