【BO-SDK】-(RAS) Add summary to a group_@old_devlib_03

xiangjinling發表於2010-09-23
Add new Summaries[@more@]

void addSummary(ReportClientDocument reportClientDocument, IField fieldToSummarize)

throws TutorialException

{

try

{

/*

* Get a DataDefController object for the given report. This controller is needed

* in order to get the summary controller. It is also used to access the report's

* groups, although groups can be accessed for reading without this controller.

*/

DataDefController dataDefController = reportClientDocument.getDataDefController();

//Create a new summary field.

SummaryField summaryField = new SummaryField();

//Set the field that will be used to calculate the summary.

summaryField.setSummarizedField(fieldToSummarize);

/*

* Get a the first group in the report using the DataDefController object.

* Set this group for the summary field using the setGroup method.

*/

IGroup group = dataDefController.getDataDefinition().getGroups().getGroup(0);

summaryField.setGroup(group);

/*

* Set the operation that will be used to calculate the summary. In this

* case, the count operation is chosen.

*/

summaryField.setOperation(SummaryOperation.count);

/*

* Add the new summary to the report using the DataDefController object. The

* argument -1 indicates that the summary will be added to the end of the list of

* summary fields.

*/

dataDefController.getSummaryFieldController().add(-1, summaryField);

}

// If any part of the above procedure failed, redirect the user to an error page.

catch (ReportSDKException e)

{

throw new TutorialException("Error while adding summary.");

}

}

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24167472/viewspace-1038829/,如需轉載,請註明出處,否則將追究法律責任。

相關文章