• Post Reply Bookmark Topic Watch Topic
  • New Topic

Opening Excel sheet in a browser

 
Sanjaykar Gurram
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
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • 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.
 
Rob Spoor
Sheriff
Posts: 20819
68
Chrome Eclipse IDE Java 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.
 
Anup Hege
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: 42970
73
  • 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: 20819
68
Chrome Eclipse IDE Java 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!