Hi Daryl(),
That is actually really easy nowadays thanks to the boys and girls behind the JasperSoft plugin. If you have the plugin in your plugins folder you can run a report like this:
Preview (shows an onscreen preview in smart client and downloads a pdf in NG-Client):
- Code: Select all
plugins.jasperPluginRMI.runReport(datasource, 'myReport.jrxml', '', plugins.jasperPluginRMI.OUTPUT_FORMAT.VIEW, [])
The datasource can be a foundset, a dataset or a viewset. A viewset is very convenient when you need data from multiple tables. Define fields in your report that match the name of your data.
To output to a printer (SmartClient only) just change the output and if you want to print to a specific printer change the output options:
- Code: Select all
plugins.jasperPluginRMI.runReport(reportDataSource, report, 'EPSON ET-2720', plugins.jasperPluginRMI.OUTPUT_FORMAT.PRINT, parameters)
You can output to CSV, DOC, XLS, XLSX, HTML, PDF, PRINT, RTF, TXT and XML.
Parameters are very convenient as well, just pass them in something like this (don' forget to define them in your report as a parameter as well using the same parameter name):
- Code: Select all
parameters = {'userName': security.getUserName(), 'nameField': foundset.name, 'someVar': someVar}
To change the locale of your report you can add an extra locale parameter. In Servoy Admin under Server plugins specify where your reports are located in the dedicated field for that. That's it!