Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Excel file generated by poi can not been downloaded in IE6?
Excel file generated by poi can not been downloaded in IE6? [message #981254] Mon, 12 November 2012 09:24
David Song is currently offline David SongFriend
Messages: 217
Registered: April 2011
Senior Member
Hi all,
in my project, I have to use rap 1.4.2 and IE6, and I want to use apache poi to generate ms excel file from the database and export excel file in IE6. My code works well in any other browsers except MS IE6. and the snippet just like below:

public void run() {
		RWT.getServiceManager().registerServiceHandler( EXCEL_SERVICE_HANDLER,  new ExcelServiceHandler("projects.xls") );
	    RWT.getSessionStore().setAttribute( EXCEL_KEY, ProjectStatisticsToExcelResourse.getExcelContent(projectTypes) );
	    
	    URL url;
		try {
			url = new URL(createPDFUrl(EXCEL_KEY));
			PlatformUI.getWorkbench().getBrowserSupport().createBrowser("DownloadDialog").openURL(url);
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (PartInitException e) {
			e.printStackTrace();
		}
	}
	
	
	private String createPDFUrl( String string ) {
	    StringBuffer url = new StringBuffer();
	    url.append(URLHelper.getURLString());
	    url.append( "?" );
	    url.append( IServiceHandler.REQUEST_PARAM );
	    url.append( "=" );
	    url.append( EXCEL_SERVICE_HANDLER );
	    url.append( "&nocache=" );
	    url.append( System.currentTimeMillis() );
	    String encodedURL = RWT.getResponse().encodeURL( url.toString() );
	    return encodedURL;
	  }



		InputStream in = (InputStream) RWT.getSessionStore().getAttribute(
				"excelKey");
		HttpServletResponse response = RWT.getResponse();
		response.setContentType("application/vnd.ms-excel");
		String contentDisposition = "attachment; filename=" + fileName;
		response.setHeader("Content-Disposition", contentDisposition);
		response.setHeader("Content-Transfer-Encoding", "binary");
		// response.setHeader("Pragma", "no-cache");
		// response.setHeader("Cache-Control", "no-cache, must-revalidate");
		//response.setContentLength(in.available());

		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		int next = in.read();
		while (next > -1) {
			bos.write(next);
			next = in.read();
		}
		bos.flush();
		byte[] result = bos.toByteArray();

		try {
			ServletOutputStream out = response.getOutputStream();
			out.write(result);
			out.flush();
		} catch (IOException e) {
			e.printStackTrace();
		}


and the attachment is the project archive file.

thank you very much

David

[Updated on: Mon, 12 November 2012 10:21]

Report message to a moderator

Previous Topic:Eclipse Juno RAP problem
Next Topic:rwt standalone rap 1.5 deployed in jboss occror error like Not installing optional component!
Goto Forum:
  


Current Time: Thu Apr 25 05:08:28 GMT 2024

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

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

Back to the top