## Integration and Usage

### Call Interface

The package XLIB_JASPERREPORTS is the interface which accepts the parameters, generates the url and calls the integration on the locally installed J2EE server.

e.g.:

begin
xlib_jasperreports.set_report_url('http://localhost:8080/JasperReportsIntegration/report');
xlib_jasperreports.show_report (p_rep_name => :p5_rep_name,
p_rep_format => :p5_rep_format,
p_data_source => :p5_data_source,
p_out_filename => :p5_out_filename,
p_rep_locale => :p5_rep_locale,
p_rep_encoding => :p5_rep_encoding,
p_additional_params => :p5_additional_params);
-- stop rendering of the current APEX page
apex_application.g_unrecoverable_error := true;
end;

Here is a description of the input parameters:

parameter | description | default value | required?
--- | --- | --- | ---
p_rep_name | specifies the report name | test | *
p_rep_format | the report format, e.g. pdf, html, html2, rtf, xls, jxl, csv, xlsx, pptx or docx | pdf | *
p_data_source | configured data source, e.g. default, test | default | *
p_out_filename | a filename can be specified for the download for the "save as" dialog |  |
p_rep_locale | Locale string, composed of the ISO language code and ISO country code | de_DE |
p_rep_encoding | the "charset" parameter for the content_type, a list of valid entries can be found here. E.g.: ISO-8859-15, UTF-8, Windows-1252 | UTF-8 |
p_additional_parameters | all parameters are passed directly to the report (excluding the the internal ones (prefixed with "_") |  |

### Deployment of reports

The report files will have to be stored on the application server. Copy the compiled version (report.jasper) of your report definition file (test.jrxml) into the directory OC_JASPER_CONFIG_HOME/reports/.

You can also create subdirectories to organize your reports. For example if you have different reports in your application application1 for sales and for controlling:

1. reports/test.jasper
2. reports/application1/sales/sales-report.jasper
3. reports/application1/controlling/controlling-report.jasper

You would use as a p_rep_name the following values:

1. p_rep_name => 'test'
2. p_rep_name => 'application1/sales/sales-report'
3. p_rep_name => 'application1/controlling/controlling-report'

### Input parameter for the reports

You can specify input parameters for the reports and use them as a filter. They have to be defined as STRING, they cannot be number or any other data type. This is due to how the integration calls the reports. See the report demo/orders.jrxml or demo/top_orders.jrxml as a sample. Both use the input parameter pAppUser for filtering the data set.

### Configuration of export properties

You can control the behaviour when exporting the report into the different report formats like pdf, html, rtf, xls, jxl, csv, xlsx, pptx or docx.

You can find the configuration reference at:
http://jasperforge.org/uploads/publish/jasperreportswebsite/trunk/config.reference.html
There are two ways how to set export properties.
1. Global export configuration properties
=========================================
JasperReports will load the "jasperreports.properties" from classpath.
In case you are using Tomcat, the properties file can be placed in this
directory (it will be initially installed here anyway):
$TOMCAT_HOME/webapps/JasperReportsIntegration/WEB-INF/classes/jasperreports.properties
Example jasperreports.properties:
--------------------------------------------------------------------------------
#
# You can find all possible configuration parameters here:
# http://jasperforge.org/uploads/publish/jasperreportswebsite/trunk/config.reference.html
#
# general export properties
#net.sf.jasperreports.export.ignore.page.margins=true
# docx export properties
net.sf.jasperreports.export.docx.frames.as.nested.tables=true
# xls export properties (also for xlsx)
net.sf.jasperreports.export.xls.white.page.background=true
net.sf.jasperreports.export.xls.one.page.per.sheet=true
#net.sf.jasperreports.export.xls.remove.empty.space.between.columns=true
#net.sf.jasperreports.export.xls.remove.empty.space.between.rows=true
# csv export properties
net.sf.jasperreports.csv.field.delimiter=\t
# html export properties
net.sf.jasperreports.export.html.output.images.to.dir=true
net.sf.jasperreports.export.html.images.dir=/reports/tmp
net.sf.jasperreports.export.html.output.images.uri=/JasperReportsIntegration/reports/tmp/
--------------------------------------------------------------------------------
2. Individual export configuration properties per report
========================================================
Properties can also be set in the jrxml file for each individual report. Therefore it is possible to use
different sets of properties for one JasperReportsIntegretion instance, because
all necessary properties are set in the compiled jasper file.
Example
--------------------------------------------------------------------------------
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports"
…
isSummaryNewPage="true" isIgnorePagination="true">
…
<property name="net.sf.jasperreports.export.xls.white.page.background"
value="false"/>
</jasperReport>
--------------------------------------------------------------------------------
You can find the configuration settings in iReport in the properties view of the report (root node)
Individual report settings will always override global settings.