• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Opening XL sheet in a URL in ms excel

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic