1.导出为excel
@Override
public ApiResult exportStandardProduction(HttpServletResponse response) {
ExcelData data = new ExcelData();
data.setName("记录");
List<String> titles = new ArrayList();
titles.add("序号");
titles.add("工程名称");
data.setTitles(titles);
List<List<Object>> rows = new ArrayList();
List<StandardProductionVO> alist = standardProductionMapper.getStandardProductionList();
if (!CollectionUtils.isEmpty(alist)){
for (int i = 0; i < alist.size(); i++) {
List<Object> row = new ArrayList();
StandardProductionVO standardProductionVO = alist.get(i);
row.add(i + 1);
row.add(standardProductionVO.getPrjName());
}
rows.add(row);
}
}
data.setRows(rows);
try {
ExcelUtils.exportExcel(response, "记录", data);
} catch (Exception e) {
e.printStackTrace();
return ApiResult.error("导出失败");
}
return ApiResult.ok().setMsg("导出成功");
}