html exported to excel when save as, defaults to web page

J

jayahn

When I export html code in the .jsp to excel, and I open the .xls file, and
try to Save As, the file type automatically defaults to webpage file. I want
it to default to .xls file.

I have tried a number of methods. I have tried exporting from the .jsp with
no code at all(basically it opens a empty .xls file). This tried to save the
..xls file as a text delimited. When I added only the <html></html> tags, it
returned to trying to save as webpage. I suspect that there must be some
tag(or at least some identification flag) that sets the Save As filetype
accordingly, but I cannot find where or what it is.

Thank you.

- Jay -
 
T

Tim Williams

What headers are you adding to the jsp response ?
Try something like:

Response.AddHeader "Content-Disposition", "inline; filename=weberport1.xls"
Response.ContentType = "application/vnd.ms-excel"

(above is ASP syntax)

Tim
 
J

jayahn

Yea, the headers that you have noted had already been added, except it's not
"inline;", its "attachment;". Sorry, I should have mentioned that. I've tried
"inline;" and not only does it default to Save As Web Page, it does not have
the option of saving as an .xls file.

- Jay -
 
J

jayahn

When I have the header:

Response.AddHeader "Content-Disposition", "attachment;
filename=weberport1..xls"

It directs the file to be opened in Excel, which is what I want. But it
still defaults to Save As Web Page. (If is "inline" instead of "attachment",
it will open in IE.)

- Jay -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top