1.在html中添加iframe
2.向后台发送请求
4.建立好excel格式,导入数据后
<iframe id="exFrame" name="exFrame" width="0" height="0"></iframe>
2.向后台发送请求
function exportExcel(){
var packForm = $("#sellStatForm");
packForm.attr("target", "exFrame");//设置链接的target为iframe
packForm.attr("action", "/zhaojin/sellstat/exportExcel");
packForm.submit();
packForm.removeAttr("target");
}
3、首先要设置contentType
response().reset();
response().setContentType ( "application/ms-excel" ) ;
response().addHeader("Content-Disposition", "attachment;filename=sellstat.xls");
4.建立好excel格式,导入数据后
OutputStream out=null;
out= new BufferedOutputStream(response().getOutputStream());
workbook.write(out);