Jody,
You need to set content-disposition header
// Set the headers.
res.setContentType("application/x-download");
res.setHeader("Content-Disposition", "attachment; filename=" + filename);
For more details see
http://www.onjava.com/pub/a/onjava/excerpt/jebp_3/index3.html
Hope this helps.
Regards,
Tahir
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 08, 2006 7:53 PM
To: [email protected]
Subject: Excel Sheet Title
Is there any way to change the default file save name and title when I
create a spreadsheet? Right now it is the name and path of my servlet.
That's totally not what I want. I searched and searched and could not
find anything. Here's my code:
In the servlet:
private void displayBUSRxsl(BusrView busrView, int langId, int currId,
HttpServletResponse response) throws Exception
{
try{
SRMCreateXls xls = new SRMCreateXls();
HSSFWorkbook wb = xls.createBUSRWorkbook(busrView, langId,
currId);
response.setContentType("application/vnd.ms-excel");
ServletOutputStream out = response.getOutputStream();
wb.write(out);
out.write(wb.getBytes());
out.close();
}
catch(Exception e){
throw new SRMException(e.getMessage());
}
}
Is it because I'm using a ServletOutputStream? The fileOutputStream lets
you create a file name whereas the ServletOutputStream does not. And I
don't see anything in POI that lets me name the file.
Also, I want to set the column width for each column. Do I have to do
that for each row? I have tried several variations of this and it seems
the only way I can get it to work is to set the column width for each row.
That seems like oeverkill to me so I'm thinking I'm just not doing it
right.
Another issue I have is that I can't set the column with:
spreadsheet.setColumnWidth((short) (0), (short) 20);
I have to use this formula.
spreadsheet.setColumnWidth((short) (0), (short) ((50 * 8) / ((double) 1 /
10)));
I played with just using a number for a long time before trying it just
like the example. Is this for real or am I missing something?
And while I'm here, why are my error messages always empty?
Thanks for any suggestions or observations.
Jody
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 268.2.0/276 - Release Date: 3/7/2006
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 268.2.0/276 - Release Date: 3/7/2006
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/