Excel Utils
Introduction
svyExcelUtils is a wrapper for Apache POI's excel library and allows to read and write xls and xlsx files directly from within Servoy.
Installation
svyExcelUtils is dependent on some external libraries, some of which are already part of Servoy's Jasper plugin. So to use the functionality, you need to install at least the basic version of the latest Jasper plugin available here: https://www.servoyforge.net/projects/servoy-jasperreports/files
Please read the following instructions carefully. Due to different signatures in different Servoy versions and different Jasper plugin versions, there are a few variants of dependencies.
Download required libraries and make jasper plugin jnlp adjustments
For support of xlsx, some additional libraries are required depending on the Servoy version you use. To let a smart client know it needs to download these libraries, some adjustments to the jnlp file of the Jasper plugin (application_server/plugins/servoy_jasperreports.jar.jnlp) need to be made. The changes needed depend on the Jasper plugin version used.
You may sign the libraries in the poi directory just as you would sign any plugin. For convenience all these libraries are signed with Servoy's certificate. So if you do not sign the application server with your own certificate, you should not run into signature problems.
Please make sure you are using the Jasper plugin version that matches the Servoy version. You can find the right version on ServoyForge. There are several downloads of the same plugin version, each signed with the code signing certificate used since a specific Servoy version. For example, for Jasper plugin version 6.4.1 you will find 3 downloads: [Package]_v.6.4.1 (Servoy version < 8.4), [Package]_v.6.4.1_svy84 (Servoy version >= 8.4) and [Package]_v.6.4.1_2019.12.1 (Servoy version >= 2019.12.1).
Servoy 2022.03.1 or later and Jasper plugin 2022.3_6.19.1 or later
Make sure you have downloaded version 1.6.1 or later of the svyUtils solution.
Then download this poi.zip and copy all the files contained in application_server/plugins/poi (make sure the directory is empty before). Now open the servoy_jasperreports.jar.jnlp file with a text editor and add this
at the end of the <resources>
element of the xml.
Servoy 2020.03 or later and Jasper plugin 6.12.2 or later
Make sure you have downloaded version 1.4.1 or later of the svyUtils solution.
Then download this poi.zip and copy all the files contained in application_server/plugins/poi (make sure the directory is empty before). Now open the servoy_jasperreports.jar.jnlp file with a text editor and add this:
at the end of the <resources>
element of the xml.
Servoy 2019.12.1 or later and Jasper plugin 6.4.1 or later
Download this poi.zip and copy all the files contained in application_server/plugins/poi (make sure the directory is empty before). Now open the servoy_jasperreports.jar.jnlp file with a text editor and add this:
at the end of the <resources>
element of the xml.
Servoy 8.1.2/7.4.9 or later and Jasper plugin 6.4.1 or later
Download this poi.zip and place all the jar files contained in application_server/plugins/poi. Now open the servoy_jasperreports.jar.jnlp file with a text editor and remove the reference to xalan-xxx.jar:
Either remove or comment these lines out (by nesting them into a comment ). Please note that this might cause problems if you use an XML datasource in any of your reports. Note that this is no longer necessary with Servoy 2019.12.1 or later (see above). To avoid conflicts in developer, rename xalan-xxx.jar inside application_server\plugins\servoy_jasperreports from ".jar" to ".unused".
Now, add the following lines to the <resources>
section of the jnlp file:
Creating Excel files
Want to get started and do the reading later? Check out the following snippet:
The resulting xlsx file looks like this:
Reading excel files
Typically, you want to access the data of an excel sheet. This code snippet shows how svyExcelUtils helps you with that (using the example xlsx file created above):
the output will look like this:
Creating Excel files from foundsets or datasets
svyExcelUtils also makes it easy to perform the probably most common task when dealing with Excel files: creating Excel from either a JSFoundSet or a JSDataSet:
The resulting xlsx file looks like this:
Last updated