For a project we need to create an .xlsm excel document automatically filled with data entered into our application. All handling of the excel document is independent from the rest of the backend, so all of the direct handling of the Excel document is moved into its own module and the project hence has the following structure
+ BaseFolder
|- settings.gradle
|- build.gradle
|
+--+ backend
| |- backend.gradle
| |- src
|
+--+ excel
|- excel.gradle
|- src
In the excel module we chose to use Apache POI to fill out the .xlsm
template file. Hence, the excel.gradle
has the following dependency
compile('org.apache.poi:poi-ooxml:3.17')
In the backend module we have to use Spring Tools to create the API and ojdbc8
to communicate with an Oracle database for persistent storage of information. This data from the database needs to be written to the excel file, why in the dependencies of backend.gradle
we have
compile project(':excel')
...
compile('com.oracle.jdbc:ojdbc8:12.2.0.1')
The excel project is used in the backend through a TemplateBuilderAdapter
, which takes the database representation and calls the corresponding methods on TemplateBuilder
.
When .write(OutputStream stream)
is called on the Apache POI XSSFWorkbook
from the TemplateBuilder
inside the excel module the file created is as it should be. On the other hand, when .write(OutputStream stream)
is called on TemplateBuilderAdapter
, which merely passes it along to TemplateBuilder
, the file is corrupted.
Given the deduction from XSSFWorkbook when written creates a corrupted .xlsx document in Spring Boot application using JDBC by compiling ojdbc8
the class path ends up changing the XML parser used by Apache POI, which leads to the corrupted Excel files. We have tried to use a fat .jar file with all dependencies of the excel project, but that was without luck.
How can we use the excel project within the backend project without the classpath of everything used in the excel project being changed? And if we have to respecify the class path to clean up after the import of ojdbc8 does anyone have any ideas as to where to what causes the conflict?