views:

472

answers:

1

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

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

Urgent Help is needed please. Thanks In Advance. ~Arun

+2  A: 

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

HSSFWorkbook#write(OutputStream)

where the output stream is the;

response.getOutputStream()

Youll probably want to do things like set the ContentType of the reponse as well as maybe some content dispostion attributes.

simon622
Hi Simon622, I used this step before but it threw me errors. My point is that I am exporting my HSSFWorkbook Object to the JSP page and I need to show the output of that object as an Excel spreadsheet without storing the resultant Excel file after HSSFWorkbook#write(OutputStream)it at the server side.
Arun
Youll need to paste the error you are receiving when attempting to write the spreadsheet to the response, if we're to be able to help you further.
simon622