This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Opening Excel sheet in a browser

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • 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: 43016
76
  • Mark post as helpful
  • send pies
  • 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: 21972
106
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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: 43016
76
  • Mark post as helpful
  • send pies
  • 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: 21972
106
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • 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
 
Stinging nettles are edible. But I really want to see you try to eat this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic