以编程方式附加Crystal报表,不使用子报表

问题描述 投票:1回答:1

我的任务是创建一个允许以下操作的“应用程序”:给定服务器上的Crystal Reports列表,用户可以选择任意数量的Crystal Reports组合成一个长报告(仅附加在一起)。他们必须能够为每个报告设置参数。

我已经收集到,通常的方法是生成一个主报告,该报告将所有单个报告都包含为子报告,但是我不认为这是一个选择,因为某些单个报告可能已经包含了自己的报告。子报表(您不能有嵌套的子报表)。

这些报告是使用Crystal Reports for Enterprise XI 4.0创建的。我正在尝试使用BusinessObjects Java SDK将其作为一组JSP页面进行操作。优选地,输出类型将是灵活的,但是如果需要,仅生成PDF是可以接受的。

解决这个问题的最佳方法是什么?

UPDATE:我还应该注意,当尝试将单个报告导出为PDF时(我正在考虑仅制作每个报告的PDF,然后以某种方式将它们串联起来),以下代码将失败:

// Get the ID of the current working report.
int reportID = Integer.parseInt(request.getParameter("ReportID"));

// Retrieve the BOE Session and InfoStore objects
IEnterpriseSession eSession = (IEnterpriseSession)session.getAttribute("EnterpriseSession");
IInfoStore iStore = (IInfoStore)eSession.getService("InfoStore",ServiceNames.OCA_I_IINFO_STORE);

// Query to get the report document
String infoStoreQuery = "select SI_NAME,SI_PARENTID from CI_INFOOBJECTS where SI_ID=" + reportID;
IInfoObjects infoObjects = iStore.query(infoStoreQuery);
IInfoObject report = (IInfoObject)infoObjects.get(0);

IReportAppFactory reportAppFactory = (IReportAppFactory)eSession.getService("RASReportFactory");
ReportClientDocument clientDoc = reportAppFactory.openDocument(report, OpenReportOptions._openAsReadOnly, java.util.Locale.CANADA);

//Use the report document's PrintOutputController to export the report to a ByteArrayInputStream
ByteArrayInputStream byteIS = (ByteArrayInputStream)clientDoc.getPrintOutputController().export(ReportExportFormat.PDF);
clientDoc.close();

//Create a byte[] that is the same size as the exported ByteArrayInputStream
byte[] buf = new byte[2000 * 1024];
int nRead = 0;
//Set response headers
response.reset();
response.setHeader("content-disposition", "inline;filename=untitled.pdf");
response.setContentType("application/pdf");
//Send the Byte Array to the Client
while ((nRead = byteIS.read(buf)) != -1) {
  response.getOutputStream().write(buf, 0, nRead);
}
//Flush the output stream
response.getOutputStream().flush();
//Close the output stream
response.getOutputStream().close();

在“ reportAppFactory.openDocument”行上,出现此错误:

javax.servlet.ServletException: com.crystaldecisions.sdk.occa.managedreports.ras.internal.ManagedRASException: Cannot open report document. --- This release does not support opening SAP Crystal Reports for Enterprise reports.

因此,如果您没有更好的解决方案来解决整个问题,即使将一份报告导出为PDF,我仍然会提供一些帮助。

java jsp crystal-reports business-objects crystal-reports-xi
1个回答
3
投票

我将答案限于您问题中最困难的部分-将输出合并到一个文件中。

除非您创建“主”报告并将每个报告作为子报告附加,否则通过Crystal Reports听起来不可能是您所描述的内容。这确实具有您提到的丢失所有已嵌入的子报表的缺点。

© www.soinside.com 2019 - 2024. All rights reserved.