public boolean run(OutputStream stream) throws ReportRunnerException,
			NoDataFoundException, InterruptedException {
        if ((stream == null) && GRAPHIC_FORMAT.equals(format)) {
            throw new ReportRunnerException("OutputStream cannot be null!");
        }

        if ((stream != null) && TABLE_FORMAT.equals(format)) {
            throw new ReportRunnerException("TABLE FORMAT does not need an output stream. Use run() method instead.");
        }

        if (connection == null) {
			throw new ReportRunnerException("Connection is null!");
		}
		if (chart == null) {
			throw new ReportRunnerException("Chart is null!");
		}

		Report report = chart.getReport();
		String sql = report.getSql();
		if (sql == null) {
			// get sql from SelectQuery object (report built with next reporter
			// !)
			sql = report.getQuery().toString();
		}
		if (sql == null) {
			throw new ReportRunnerException("Report sql expression not found");
		}
		
		try {
			setDynamicColumns();
		} catch (Exception e1) {
			throw new ReportRunnerException(e1);
		}

		// retrieves the report parameters
		Map<String, QueryParameter> parameters = new HashMap<String, QueryParameter>();
		List<QueryParameter> parameterList = report.getParameters();
		if (parameterList != null) {
			for (QueryParameter param : parameterList) {
				parameters.put(param.getName(), param);
			}
		}

		if (QueryUtil.restrictQueryExecution(sql)) {
			throw new ReportRunnerException(
					"You are not allowed to execute queries that modify the database!");
		}

		if (QueryUtil.isProcedureCall(sql)) {
			Dialect dialect = null;
			try {
				dialect = DialectUtil.getDialect(connection);
			} catch (Exception e) {
				e.printStackTrace();
			}
			if (!QueryUtil.isValidProcedureCall(sql, dialect)) {
				throw new ReportRunnerException(
						"Invalid procedure call! Must be of form 'call (${P1}, ?)'");
			}
		}

		QueryExecutor executor =  null;
		try {
			Query query = new Query(sql);
			executor = new QueryExecutor(query, parameters, parameterValues, connection, true, true, csv);
			executor.setMaxRows(0);
			executor.setTimeout(queryTimeout);

			QueryResult queryResult = executor.execute();

			createExporter(query, parameters, parameterValues, queryResult, stream);
            return exporter.export();

		} catch (NoDataFoundException e) {
			throw e;
        } catch (InterruptedException e) {
            throw e;
        } catch (Exception e) {
            e.printStackTrace();
            throw new ReportRunnerException(e);
		} finally {
			resetStaticColumnsAfterRun();
        	if (executor != null) {
        		executor.close();
        	}        	
        }
	}
public boolean run ( OutputStream stream ) throws ReportRunnerException , NoDataFoundException , InterruptedException { if ( ( stream == null ) && GRAPHIC_FORMAT . equals ( format ) ) { throw new ReportRunnerException ( "OutputStream cannot be null!" ) ; } if ( ( stream != null ) && TABLE_FORMAT . equals ( format ) ) { throw new ReportRunnerException ( "TABLE FORMAT does not need an output stream. Use run() method instead." ) ; } if ( connection == null ) { throw new ReportRunnerException ( "Connection is null!" ) ; } if ( chart == null ) { throw new ReportRunnerException ( "Chart is null!" ) ; } Report report = chart . getReport ( ) ; String sql = report . getSql ( ) ; if ( sql == null ) { sql = report . getQuery ( ) . toString ( ) ; } if ( sql == null ) { throw new ReportRunnerException ( "Report sql expression not found" ) ; } try { setDynamicColumns ( ) ; } catch ( Exception e1 ) { throw new ReportRunnerException ( e1 ) ; } Map < String , QueryParameter > parameters = new HashMap < String , QueryParameter > ( ) ; List < QueryParameter > parameterList = report . getParameters ( ) ; if ( parameterList != null ) { for ( QueryParameter param : parameterList ) { parameters . put ( param . getName ( ) , param ) ; } } if ( QueryUtil . restrictQueryExecution ( sql ) ) { throw new ReportRunnerException ( "You are not allowed to execute queries that modify the database!" ) ; } if ( QueryUtil . isProcedureCall ( sql ) ) { Dialect dialect = null ; try { dialect = DialectUtil . getDialect ( connection ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } if ( ! QueryUtil . isValidProcedureCall ( sql , dialect ) ) { throw new ReportRunnerException ( "Invalid procedure call! Must be of form 'call (${P1}, ?)'" ) ; } } QueryExecutor executor = null ; try { Query query = new Query ( sql ) ; executor = new QueryExecutor ( query , parameters , parameterValues , connection , true , true , csv ) ; executor . setMaxRows ( 0 ) ; executor . setTimeout ( queryTimeout ) ; QueryResult queryResult = executor . execute ( ) ; createExporter ( query , parameters , parameterValues , queryResult , stream ) ; return exporter . export ( ) ; } catch ( NoDataFoundException e ) { throw e ; } catch ( InterruptedException e ) { throw e ; } catch ( Exception e ) { e . printStackTrace ( ) ; throw new ReportRunnerException ( e ) ; } finally { resetStaticColumnsAfterRun ( ) ; if ( executor != null ) { executor . close ( ) ; } } }
Export the current chart to the specified output format
For IMAGE_FORMAT use withImagePath method.

@param stream output stream to write the exported chart
@throws ReportRunnerException if ChartRunner object is not correctly configured
@throws NoDataFoundException if chart has no data
@throws InterruptedException if process was interrupted
@return true if export process finished, or false if export process crashed