Use apache poi (to read and write to .xlsx spreadsheet) for the customized plugin which implements BulkFileListener


I have implemented a customized BulkFileListener, where I have implemented the @Override function public void after(@NotNull List<? extends VFileEvent> events).   Based on certain conditions, I want to read/write to a xlsx spreadsheet using apache poi.

Let me know how to include appropriate dependencies in build.gradle file, so that I am able to successfully import org.apache.poi.xssf.usermodel.XSSFWorkbook;



Comment actions Permalink

I got it working to compile & build successfully by including the following in the dependencies section of build.gradle file

implementation 'commons-io:commons-io:2.11.0
implementation 'org.apache.poi:poi:5.2.2'
implementation 'org.apache.poi:poi-ooxml:5.2.2'
implementation 'org.apache.poi:poi-ooxml-schemas:4.1.2'
implementation 'dom4j:dom4j:1.6.1'
implementation 'org.apache.xmlbeans:xmlbeans:5.1.0'
implementation 'org.apache.poi:openxml4j:1.0-beta'


However while running am getting the below error at the place where the XSSFWorkbook is instantiated.

java.lang.NoClassDefFoundError: org/apache/poi/xssf/usermodel/XSSFWorkbook


What could be the reason for this.?

Comment actions Permalink

Am I missing something important in the configuration

Comment actions Permalink

You'll need to figure out all required dependencies of this library according to its documentation. On a sidenote, this listener should not be used for heavy operations like writing to a file. So I suggest to just perform quick operations from it and update file contents asynchronously.

Comment actions Permalink

Ok. I will push all the heavy operations to a task which runs periodically to do the asyncronous tasks...

Let me know the class/interface that I need to extend/implement to invoke the scheduled task... A sample code snippet or appropriate links will help.


Please sign in to leave a comment.