Boa tarde Pessoal,
Tenho o seguinte metodo para imprimir relatorios no crystal
<%@page import="com.br.model.Parametros"%>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="ISO-8859-1" %>
<%@ page import="com.businessobjects.CRJavaHelper"%>
<%@ page import="com.crystaldecisions.report.web.viewer.CrystalReportViewer"%>
<%@ page import="com.crystaldecisions.sdk.occa.report.application.OpenReportOptions"%>
<%@ page import="com.crystaldecisions.sdk.occa.report.application.ReportClientDocument"%>
<%@ page import="com.crystaldecisions.sdk.occa.report.lib.ReportSDKExceptionBase"%>
<%@ page import="java.sql.Connection"%>
<%@ page import="java.sql.DriverManager"%>
<%@ page import="java.sql.ResultSet"%>
<%@ page import="java.sql.SQLException"%>
<%@ page import="java.sql.Statement"%>
<%@ page import="com.br.util.funcoesCrystalReports"%>
<%@ page import="java.util.logging.Logger"%>
<%
// This sample code calls methods from the CRJavaHelper class, which
// contains examples of how to use the BusinessObjects APIs. You are free to
// modify and distribute the source code contained in the CRJavaHelper class.
funcoesCrystalReports crystal = new funcoesCrystalReports();
Parametros param = crystal.getParametros();
Logger logger = Logger.getLogger("br.com.log");
String reportName = "report/"+crystal.getReport(request)+".rpt";
ReportClientDocument clientDoc = (ReportClientDocument) session.getAttribute(reportName);
// Report can be opened from the relative location specified in the CRConfig.xml, or the report location
// tag can be removed to open the reports as Java resources or using an absolute path
// (absolute path not recommended for Web applications).
clientDoc = new ReportClientDocument();
clientDoc.setReportAppServer(ReportClientDocument.inprocConnectionString);
// Open report
clientDoc.open(reportName, OpenReportOptions._openAsReadOnly);
// ****** BEGIN POPULATE WITH RESULTSET SNIPPET ****************
{
// **** POPULATE MAIN REPORT ****
{
// Connection Info for fetching the resultSet
String connectStr = param.getDSC_STRING_CONNECTION();
String driverName = param.getDSC_DRIVER_NAME();
String userName = param.getDSC_USER();
String password = param.getDSC_PASSWORD();
//Ensure this query is valid in your database. An exception will be thrown otherwise. 21006176
//String query = "SELECT CUSTOMER_NAME FROM APP.CUSTOMER WHERE COUNTRY = 'Australia'"; '
String query = crystal.getConsulta(request);
logger.info("Consulta do Relatorio : " + query);
// As long the Resultset schema has the same field names and types,
// then the Resultset can be used as the datasource for the table
String tableAlias = crystal.getAlias(request); // Change to correct table alias
// Push the Java ResultSet into the report (this will then be the datasource of the report)
CRJavaHelper.passResultSet(clientDoc, crystal.getfetchResultSet(driverName, connectStr, userName, password, query),
tableAlias, "");
}
}
// Store the report document in session
session.setAttribute(reportName, clientDoc);
// ****** BEGIN CONNECT CRYSTALREPORTPAGEVIEWER SNIPPET ****************
{
// Create the CrystalReportViewer object
CrystalReportViewer crystalReportPageViewer = new CrystalReportViewer();
String reportSourceSessionKey = reportName+"ReportSource";
Object reportSource = session.getAttribute(reportSourceSessionKey);
//if (reportSource == null)
//{
reportSource = clientDoc.getReportSource();
session.setAttribute(reportSourceSessionKey, reportSource);
//}
// set the reportsource property of the viewer
crystalReportPageViewer.setReportSource(reportSource);
// Apply the viewer preference attributes
crystalReportPageViewer.setEnableDrillDown(false);
// Process the report
crystalReportPageViewer.processHttpRequest(request, response, application, null);
}
// ****** END CONNECT CRYSTALREPORTPAGEVIEWER SNIPPET ****************
%>
Ate ai, tudo ok, porem, no momento, preciso fazer um relatorio que possui um subreport, alguem poderia me ajudar ?