Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to save poi HSSF workbook from browser

jackpotApr 7 2014 — edited Apr 10 2014

Hello,

I am working on Fusion Web Application and MySql database. I have created a poi HSSFWorkbook from pivot table and i want to save if from browser.

My code is:

    ExternalContext ectx = FacesContext.getCurrentInstance().getExternalContext();
    HttpServletResponse response = (HttpServletResponse) ectx.getResponse();
    HttpServletRequest request = (HttpServletRequest) ectx.getRequest();
    try {
        OutputStream out = response.getOutputStream();
        String str = "attachment; filename=" + fileName;
        response.setHeader("Content-Disposition", str);
        response.addHeader("Content-Type", "application/vnd.ms-excel");
        projectWorkbook.write(out);
        out.flush();
        out.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

The browser don't show the 'save as' dialog window and i don't found the reason.

If i write the file directly on server, this work.

Can anyone tell me where is the error?

Thanks

Jacques

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 8 2014
Added on Apr 7 2014
5 comments
2,396 views