JeeSite中Excel实例(解决ajax导出失效的问题)

使用ajax导出会出现导出按钮失效的问题,建议使用如下的导出方式:
使用隐藏iframe实现无刷新下载文件
前台
download
 
 function downloadFile(){
 var dom=document.getElementById('ifile');
 dom.class="lazy" src="//p2.ttnews.xyz/loading.gif" data-original="//p2.ttnews.xyz/5fd576a73204792926983baa.jpg";
后台
@RequestMapping(value = "exportData")
public void exportData(PurchaseMaterial purchaseMaterial,String materialProducer,String materialSupplier,HttpServletResponse response) {
purchaseMaterial.setMaterialStatus(1);
purchaseMaterial.setMaterialProducer(materialProducer);
purchaseMaterial.setMaterialSupplier(materialSupplier);
List list = purchaseMaterialService.findList(purchaseMaterial);
 if(list.size()>0){
 String fileName = "采购物料详细表-"+materialProducer+ DateUtils.getDate("yyyyMMddHHmmss") + ".xlsx";
 try(ExcelExport ee = new ExcelExport(materialProducer, PurchaseMaterial.class)){
 ee.setDataList(list).write(response, fileName);
 }
 }
}


分享到:


相關文章: