Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Opening XL sheet in a URL in ms excel

 
Ranjeeth Chandra
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Consider I have a URL - http://someurl/file.xls

I need to do a response.sendRedirect(url) into this url. This opens the file in the browser itself. But I need to open it in microsoft excel.

Normally we have a the content of the excel file (html table format)
then we do response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment; filename=data.xls");
outwriter.writeln(html table content);

this gives us the content in an ms excel window rather than browser. Instead of attachment above if we say inline, it'll open the contents in the browser itself but will look like excel but goofier.

The content when too large can't be manipulated on the server due to memory issues so I want to do have the file in a url link and do sendRedirect, but open it in msexcel itself.

Is it possible? Could anyone please help me in solving this?

Thanks
Ranji
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ranjeeth Chandra wrote:Hi all,
The content when too large can't be manipulated on the server due to memory issues
If you buffer the streams you don't need to worry about it.
How to buffer the streams is covered by every decent Java IO tutorial.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whether a particular file type will be opened in the browser or in a special application like Excel is a browser setting that each user can set on their own. E.g., in Firefox, look at Preferences -> Applications.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wouldn't ask every client to do so, so that the original code just works. To open a file in an external application, the only reliable way is to set content disposition to attachment. And that's not possible with a sendredirect as it creates a brand new request and thus also a brand new response -where you don't have control over.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To open a file in an external application, the only reliable way is to set content disposition to attachment.

Yes. But that's not sufficient if the browser is set to open the file using the plugin.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To my experience, that applies to responses with content-disposition=inline only.

When content-disposition=attachment, the client will be asked to open or save the file. In the 'open' option, always the external application is selected by default, regardless of the default setting for inline requests.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic