用window.open(url)的方式来导出excel表格在FF下没有任何问题,只要把站点设置成信任就可以了
但是在IE8下面就不行,当新打开一个窗口后你点downfile,他就没反应了。因为他已经拦截了第一次的请求所以你的发两次请求。
解决方法如下:
public void exportToExcel(ActionEvent event){
String url = "frameset?__format=xls&__report=reports%2FRateCard%2FexportRateCard.rptdesign&__id=birtViewer&__masterpage=true&__fittopage=false&__pagebreakonly=false&__asattachment=true&__overwrite=true&ratecard="+this.rateCardDbId;
JavascriptContext.addJavascriptCall(FacesContext.getCurrentInstance(), "var w = window.open('"+url+"','_blank'); w.location.href = '"+ url + "';");
}
如果用javascript就是:
function export(url){ var w = window.open(url,'_blank'); w.location.href = url; }
这样就能解决IE8 拦截打开excel文件的请求了