Unable to instantiate an object of XSSFWorkbook in Java servlet

590 views Asked by At

I'm trying to work with XSSFWorkbook in my web application. I ran a sample application with XSSFWorkbook as a plain Java program (with public static void main(String args[])) - it runs fine - an excel sheet is generated.

However, when I run the same piece of code in my java based web application - an instance of XSSFWorkbook is not instantiated. No Exception is thrown either!

Please help!

1

There are 1 answers

3
Yusuf Kapasi On
the below code works perfectly fine for me

public void trackerUploadListener(FileUploadEvent event) throws Exception {
    UploadedFile tracker = event.getUploadedFile();
    XSSFWorkbook wb = null;
    InputStream stream = tracker.getInputStream();
    wb = new XSSFWorkbook(stream);  
}
Here, the listener is called from my xhtml page.