解决导出excel的报错

This commit is contained in:
季圣华
2019-07-30 23:17:28 +08:00
parent 5e1a899f7b
commit 20d932bdd2
2 changed files with 4 additions and 24 deletions

View File

@@ -553,16 +553,13 @@ public class DepotItemController {
* @return * @return
*/ */
@GetMapping(value = "/exportExcel") @GetMapping(value = "/exportExcel")
public BaseResponseInfo exportExcel(@RequestParam("currentPage") Integer currentPage, public void exportExcel(@RequestParam("currentPage") Integer currentPage,
@RequestParam("pageSize") Integer pageSize, @RequestParam("pageSize") Integer pageSize,
@RequestParam("projectId") Integer projectId, @RequestParam("projectId") Integer projectId,
@RequestParam("monthTime") String monthTime, @RequestParam("monthTime") String monthTime,
@RequestParam("headIds") String headIds, @RequestParam("headIds") String headIds,
@RequestParam("materialIds") String materialIds, @RequestParam("materialIds") String materialIds,
HttpServletRequest request, HttpServletResponse response)throws Exception { HttpServletRequest request, HttpServletResponse response) {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
String message = "成功";
try { try {
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(headIds, materialIds, (currentPage-1)*pageSize, pageSize); List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(headIds, materialIds, (currentPage-1)*pageSize, pageSize);
//存放数据json数组 //存放数据json数组
@@ -604,16 +601,9 @@ public class DepotItemController {
} }
File file = ExcelUtils.exportObjectsWithoutTitle(title, names, title, objects); File file = ExcelUtils.exportObjectsWithoutTitle(title, names, title, objects);
ExportExecUtil.showExec(file, file.getName() + "-" + monthTime, response); ExportExecUtil.showExec(file, file.getName() + "-" + monthTime, response);
res.code = 200;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
message = "导出失败";
res.code = 500;
} }
/**
* 2019-01-15response已经返回finally部分完全没必要
* */
return res;
} }
/** /**

View File

@@ -292,15 +292,12 @@ public class SupplierController {
* @return * @return
*/ */
@GetMapping(value = "/exportExcel") @GetMapping(value = "/exportExcel")
public BaseResponseInfo exportExcel(@RequestParam("supplier") String supplier, public void exportExcel(@RequestParam("supplier") String supplier,
@RequestParam("type") String type, @RequestParam("type") String type,
@RequestParam("phonenum") String phonenum, @RequestParam("phonenum") String phonenum,
@RequestParam("telephone") String telephone, @RequestParam("telephone") String telephone,
@RequestParam("description") String description, @RequestParam("description") String description,
HttpServletRequest request, HttpServletResponse response)throws Exception { HttpServletRequest request, HttpServletResponse response) {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
String message = "成功";
try { try {
List<Supplier> dataList = supplierService.findByAll(supplier, type, phonenum, telephone, description); List<Supplier> dataList = supplierService.findByAll(supplier, type, phonenum, telephone, description);
String[] names = {"名称", "类型", "联系人", "电话", "电子邮箱", "预收款", "期初应收", "期初应付", "备注", "传真", "手机", "地址", "纳税人识别号", "开户行", "账号", "税率", "状态"}; String[] names = {"名称", "类型", "联系人", "电话", "电子邮箱", "预收款", "期初应收", "期初应付", "备注", "传真", "手机", "地址", "纳税人识别号", "开户行", "账号", "税率", "状态"};
@@ -331,16 +328,9 @@ public class SupplierController {
} }
File file = ExcelUtils.exportObjectsWithoutTitle(title, names, title, objects); File file = ExcelUtils.exportObjectsWithoutTitle(title, names, title, objects);
ExportExecUtil.showExec(file, file.getName(), response); ExportExecUtil.showExec(file, file.getName(), response);
res.code = 200;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
message = "导出失败";
res.code = 500;
} finally {
map.put("message", message);
res.data = map;
} }
return res;
} }
/** /**