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
* summary fields.
*/
dataDefController.getSummaryFieldController().add(
}
// 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博客 ” ,链接:https://blog.itpub.net/24167472/viewspace-1038829/ ,如需转载,请注明出处,否则将追究法律责任。