• 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

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

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 334
2
Netbeans IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 297
5
Android Firefox Browser Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 297
5
Android Firefox Browser Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Crowther wrote:Changing the file extension won't change the file format

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic