| | |
| | | @ApiOperation("模板下载") |
| | | public void download() { |
| | | try { |
| | | //ArrayList<TbDept> list = new ArrayList<>(); |
| | | //ExcelUtil.exportExcel(list, "部门导入模板", "部门导入模板", TbDept.class, "部门导入模板", response); |
| | | // ArrayList<TbDept> list = new ArrayList<>(); |
| | | // ExcelUtil.exportExcel(list, "部门导入模板", "部门导入模板", TbDept.class, "部门导入模板", response); |
| | | // 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | |
| | | String fileName = URLEncoder.encode("部门导入模板", "UTF-8"); |
| | | response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); |
| | | Map<Integer, String[]> selectedMap = new HashMap<>(); |
| | | selectedMap.put(3, new String[]{"省本级", "市", "开发区", "县"}); |
| | | selectedMap.put(3, new String[]{"省", "市", "开发区", "县"}); |
| | | selectedMap.put(4, new String[]{"是", "否"}); |
| | | EasyExcel.write(response.getOutputStream(), DeptExcel.class).sheet("模板") |
| | | .registerWriteHandler(EasyExcelUtil.getStyleStrategy()) |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R<Void> importExcel(@RequestPart("file") MultipartFile file) { |
| | | try { |
| | | //tbDeptService.importExcel(file); |
| | | // tbDeptService.importExcel(file); |
| | | InputStream inputStream = file.getInputStream(); |
| | | EasyExcel.read(inputStream, DeptExcel.class, new DeptImportListener(sysUserService)) |
| | | .sheet().doRead(); |