Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Force Download CSV in IE9(Force Download CSV in IE9)
Force Download CSV in IE9 [message #972314] Mon, 05 November 2012 14:29 Go to next message
Tobias Semmet is currently offline Tobias SemmetFriend
Messages: 37
Registered: July 2009
Member
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 15:31 Go to previous message
Cole Markham is currently offline Cole MarkhamFriend
Messages: 133
Registered: July 2009
Senior Member
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
Previous Topic:SWT.VIRTUAL & SWT.CHECK table
Next Topic:Compression of communication in Rap 2.0
Goto Forum:
  


Current Time: Fri Nov 21 04:52:15 GMT 2014

Powered by FUDForum. Page generated in 0.15537 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software