poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Fisher <dfis...@jmlafferty.com>
Subject Re: HSSFWorkbook setExportName without using workbook.write(fos))
Date Thu, 13 Jan 2011 17:06:12 GMT
Hi Thomas,

> Is it possible to set the exportName without using
> workbook.write(fileOutputStream)?
> 
> My Problem is that even if I set 
> 
> "resp.setHeader("Content-Disposition", "filename=" + "MyExample.xls");"

Are you in a servlet? You should be. Serving a binary file from jsp is not recommended.

Both ContentType and Content-disposition are important to get correct. Your disposition is
not completely correct. The following works for us.

        public void doGet(HttpServletRequest request, HttpServletResponse response) throws
IOException {
        try {
            response.setContentType("application/vnd.ms-excel");
            response.setHeader("Content-disposition", "attachment;filename=MyExample.xls");
            write(response.getOutputStream());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public void write(OutputStream out) throws Exception {
        HSSFWorkbook wb = new HSSFWorkbook();
        write(wb);
        wb.write(out);
    }

    public void write(HSSFWorkbook wb) throws Exception {
	.....
    }

> the exportName is "Export.xls" or "Export[1].xls".

What browser are you using? Some browsers can be set to override the content disposition behavior
chosen by the server.

Regards,
Dave

> 
> regards
> 
> thomas
> -- 
> View this message in context: http://apache-poi.1045710.n5.nabble.com/HSSFWorkbook-setExportName-without-using-workbook-write-fos-tp3339661p3339661.html
> Sent from the POI - User mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Mime
View raw message