• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Customize 'Save As' dialog box provided by browser at client side

 
shubham pateriya
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am developing a code in Java the problem I am facing is like this: I need to download a excel file on client side, when user hit the 'Download' button,a Pop up with 'Save', 'Open' and 'Cancel' button appears which is provided by browser, when user will click on 'Save' button, a 'Save As' dialog box opens which is again provided by browser, in this dialog box there is 'Save As Type' dropdown, I need to customize this dropdown and I want to show '.xls' and '.xlsx' extention type in this dropdown, and when user chooses any of extention type , file saves in that formate. So is it possible to customize client side browser given 'Save As' dialog Box and if yes than how?? Please asnwer as soon as possible.
 
Joe Areeda
Ranch Hand
Posts: 331
2
Java Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think this is possible from the server side or with Javascript, at least I don't know of any way to do it. In my understanding the only way to do that would be with a Java applet that had the appropriate permissions.

How about a drop down menu to select format on the same page as the download button?

Also if save is your only option perhaps you're not setting the mime type of the file. If you were I would expect an open option which would open the file in Excel and it could be saved in any supported format from there.

I wish I had a better answer for you. I'll be watching the thread for someone to show us how to do what you asked.

Joe
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65124
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot customize the browser's dialog. In fact, different browsers will do slightly different things. Just be sure that your response headers are correctly set so that the browser can do the "most right" thing with your response.
 
Rob Crowther
author
Ranch Hand
Posts: 297
5
Android Fedora Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It doesn't sound to me like you really do want to customize the save dialogue. The reason I'm saying this is because you say:
shubham pateriya wrote:in this dialog box there is 'Save As Type' dropdown, I need to customize this dropdown and I want to show '.xls' and '.xlsx' extention type in this dropdown, and when user chooses any of extention type , file saves in that formate.

Changing the file extension won't change the file format, if you want the file to be in a certain format you have to generate in that format on the server. All of the things you want to do happen on the server side, not at the client, by the time things have gotten to the save as dialogue on the client it's too late to be doing them.

If you want to force a file download, set the content-disposition header on the server side and ensure you've set an appropriate MIME type for the format of the file you've generated.
 
shubham pateriya
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Crowther wrote:It doesn't sound to me like you really do want to customize the save dialogue. The reason I'm saying this is because you say:
shubham pateriya wrote:in this dialog box there is 'Save As Type' dropdown, I need to customize this dropdown and I want to show '.xls' and '.xlsx' extention type in this dropdown, and when user chooses any of extention type , file saves in that formate.

Changing the file extension won't change the file format, if you want the file to be in a certain format you have to generate in that format on the server. All of the things you want to do happen on the server side, not at the client, by the time things have gotten to the save as dialogue on the client it's too late to be doing them.

If you want to force a file download, set the content-disposition header on the server side and ensure you've set an appropriate MIME type for the format of the file you've generated.




Hi..Thanks All of you for Answring my question..can it be done at this way....through my code I only provide byteArrayOutputStream and send it to client side...where client chooses the extention type from 'Save As' dialog box provided by browser(.xls or .xlsx) and somehow with the use of client side java script or ay other way we can download file in that formate
 
Rob Crowther
author
Ranch Hand
Posts: 297
5
Android Fedora Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Crowther wrote:Changing the file extension won't change the file format
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic