用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文件的請求了