You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by gipsy <sp...@gmail.com> on 2011/01/13 13:02:59 UTC

HSSFWorkbook setExportName without using workbook.write(fos))

Dear all

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");"

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

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


Re: HSSFWorkbook setExportName without using workbook.write(fos))

Posted by gipsy <sp...@gmail.com>.
Hi

I know the need for the "attachment"-extension in the response-header. But
this causes some problems in our program. It was stable without attachment
and we also have the option "open/save" in the browser.

I followed your instructions and extended my response-header-code with
"attachment;" The other things are already implemented. But everytime I only
get the option to open or save "Export.xls"

I use IE and Firefox. Do you still have some ideas which could possibly
help?

best regards!
-- 
View this message in context: http://apache-poi.1045710.n5.nabble.com/HSSFWorkbook-setExportName-without-using-workbook-write-fos-tp3339661p3340893.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


Re: HSSFWorkbook setExportName without using workbook.write(fos))

Posted by David Fisher <df...@jmlafferty.com>.
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