Is there a way to display the HSSFWorkbook object in a JSP page?

Is there a way to render an HSSFWorkbook object in a JSP page without having an output file on the server side? In the code below, I provide a template file and beans for net.sf.jxls.transformer.XLSTransformer.transformXLS (InputStream is, Map beanParams) to return the HSSFWorkbook object to me. Now I need a way to use this object in JSP without having to store the output file on the server side using an OutputStream.

InputStream is = new BufferedInputStream(new FileInputStream(templateFileName));
HSSFWorkbook hm = transformer.transformXLS(is, beans);
req.getSession().setAttribute("excelWorkBook",hm);

      

0


a source to share


1 answer


Looks simple, write an HSSFWorkbook using the write method on your instance;

HSSFWorkbook#write(OutputStream)

      

where the output stream is:



response.getOutputStream()

      

You probably want to do things like set the ContentType of the response, as well as some content distribution attributes.

+2


a source







All Articles