Force Download CSV in IE9 [message #972314] |
Mon, 05 November 2012 09:29  |
Eclipse User |
|
|
|
Hi,
i want to force that the user have to download a csv file and open it in excel, at the moment the csv file is shown as a plane text in the browser....
Browser browser = new Browser(shell, style);
browser.setURL("......csv");
....
Can you help me please,
thanks.
|
|
|
Re: Force Download CSV in IE9 [message #972381 is a reply to message #972314] |
Mon, 05 November 2012 10:31  |
Eclipse User |
|
|
|
If you want to display it and have the user download it, then you will need to open it twice in the user's browser. See the FAQ entry for providing a download link[1] which has an example of using a ServiceHandler to set the appropriate headers to force the download. You will probably want to set the content type appropriately. Setting the url into a Browser widget should work for displaying the file. A common approach for initiating the download is to use a hidden Browser widget (size 0x0), but that will often get blocked in IE. The most reliable method is described in the FAQ which is to provide a link for the user to click.
Another idea would be to wrap your CSV in an HTML page for displaying in the Browser widget, and in the HEAD of that HMTL put a meta refresh tag like this:
<meta HTTP-EQUIV="REFRESH" content="5; url=/service-handler-url?download=true">
That should give the content time to load, then "redirect" to the download version which will actually leave the original content in place. It's kind of a hack, but it may work for what you need.
Hope that helps,
Cole
[1] http://wiki.eclipse.org/RAP/FAQ#How_to_provide_a_download_link.3F
|
|
|
Powered by
FUDForum. Page generated in 0.04308 seconds