Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Opening Excel sheet in a browser

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I am generating an excel sheet in the java side using POI. This happens when the user clicks a button the screen.
But the generated file opens with file File Download(with Open, Save, Cancel options).

Instead i want my generated file to be opened in a new browser and embed the file inside it.
How do i achieve this through java.

Please let me know if anything else you require from my side.

Sanjaykar
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Make sure you set the Content-Disposition header to "inline", not "attachment".

But ultimately, it's up the client - if the browser is configured to open the dialog box for such files, then there's nothing the web app can do about that.
 
Sheriff
Posts: 22796
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The browser needs a plugin to display any "alien" files inline. That includes PDF files, Java applets, video and definitely MS Office files.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:Make sure you set the Content-Disposition header to "inline", not "attachment".

But ultimately, it's up the client - if the browser is configured to open the dialog box for such files, then there's nothing the web app can do about that.



@Ulf,
I have tried with to open the excel sheet with Inline files i.e. I have set the Content-Disposition header to "inline".
But still the Browser is opening up a Dialog box with "Open", "Save" and "Cancel" buttons.
Would be helpfull If I can avoid this ?

Also If the Excel sheet Open's Inline inside the browser I am unable to get the Menu bar as a result of which I am not able to save the excel sheet directly by clicking the save button. The menu bar of an Excel sheet doesnt come up inline inside a Web browser as shown in the example in the URL mentioned below.

Inline Excel Sheet Example

The excel sheet is opened by a JSP page which has been included in the form of an iframe in the parent JSP page.
I have set the following parameters in the code.
 
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

I have tried with to open the excel sheet with Inline files i.e. I have set the Content-Disposition header to "inline".
But still the Browser is opening up a Dialog box with "Open", "Save" and "Cancel" buttons.

Also If the Excel sheet Open's Inline inside the browser


I'm confused. Which one of these is it? They can't both be true.
 
Rob Spoor
Sheriff
Posts: 22796
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to be careful when using JSP files to create binary data. Each character outside of the JSP tags, including line breaks, are still part of the output. You need to put all line breaks inside your tags. So instead of
write
 
reply
    Bookmark Topic Watch Topic
  • New Topic