| | |
| | | import com.panzhihua.common.service.user.UserService; |
| | | import com.panzhihua.common.utlis.*; |
| | | import com.panzhihua.community_backstage.config.SFTPConfig; |
| | | import com.panzhihua.community_backstage.excel.CustemSecondhandler; |
| | | import com.panzhihua.community_backstage.excel.Custemhandler; |
| | | import com.panzhihua.community_backstage.excel.CustomSheetWriteHandler; |
| | | import io.swagger.annotations.Api; |
| | |
| | | headList.add(head2); |
| | | //数据转换 |
| | | datalist = HomeQuarantineUtil.ReserveData(questnaireAnswersDTOS.getAnswers()); |
| | | WriteCellStyle headWriteCellStyle = new WriteCellStyle(); |
| | | //设置头居中 |
| | | headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER); |
| | | //设置头字体 |
| | | WriteFont headWriteFont = new WriteFont(); |
| | | headWriteFont.setFontHeightInPoints((short)6); |
| | | headWriteFont.setBold(true); |
| | | headWriteCellStyle.setWriteFont(headWriteFont); |
| | | |
| | | |
| | | WriteCellStyle contentWriteCellStyle = new WriteCellStyle(); |
| | | //设置表格内容字体 |
| | | WriteFont writeFont = new WriteFont(); |
| | | writeFont.setFontHeightInPoints((short)6); |
| | | //设置 水平居中 |
| | | contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.LEFT); |
| | | //设置 垂直居中 |
| | | contentWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER); |
| | | contentWriteCellStyle.setWriteFont(writeFont); |
| | | |
| | | contentWriteCellStyle.setWrapped(true); |
| | | HorizontalCellStyleStrategy horizontalCellStyleStrategy = |
| | | new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle); |
| | | |
| | | |
| | | excelWriter = EasyExcel.write(fileName) |
| | | .registerWriteHandler(horizontalCellStyleStrategy).registerWriteHandler(new CustemSecondhandler()) |
| | | .build(); |
| | | WriteSheet writeSheet = EasyExcel.writerSheet("登记明细导出数据").head(headList).build(); |
| | | excelWriter.write(datalist, writeSheet); |
| | | excelWriter.finish(); |
| | | File file = new File(fileName); |
| | | inputStream = new FileInputStream(file); |
| | | sftp.uploadMore(ftpUrl, name, inputStream); |
| | | sftp.logout(); |
| | | inputStream.close(); |
| | | String absolutePath = file.getAbsolutePath(); |
| | | boolean delete = file.delete(); |
| | | log.info("删除excel【{}】结果【{}】", absolutePath, delete); |
| | | } |
| | | else { |
| | | String firstRowContent = "登记明细"; |
| | |
| | | }); |
| | | //数据转换 |
| | | datalist = AssemblyUtils.ReserveData(questnaireAnswersDTOS.getAnswers()); |
| | | WriteCellStyle headWriteCellStyle = new WriteCellStyle(); |
| | | //设置头居中 |
| | | headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER); |
| | | //设置头字体 |
| | | WriteFont headWriteFont = new WriteFont(); |
| | | headWriteFont.setFontHeightInPoints((short)6); |
| | | headWriteFont.setBold(true); |
| | | headWriteCellStyle.setWriteFont(headWriteFont); |
| | | |
| | | |
| | | WriteCellStyle contentWriteCellStyle = new WriteCellStyle(); |
| | | //设置表格内容字体 |
| | | WriteFont writeFont = new WriteFont(); |
| | | writeFont.setFontHeightInPoints((short)6); |
| | | //设置 水平居中 |
| | | contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER); |
| | | //设置 垂直居中 |
| | | contentWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER); |
| | | contentWriteCellStyle.setWriteFont(writeFont); |
| | | |
| | | contentWriteCellStyle.setWrapped(true); |
| | | HorizontalCellStyleStrategy horizontalCellStyleStrategy = |
| | | new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle); |
| | | |
| | | |
| | | excelWriter = EasyExcel.write(fileName) |
| | | .registerWriteHandler(horizontalCellStyleStrategy).registerWriteHandler(new Custemhandler()) |
| | | .build(); |
| | | WriteSheet writeSheet = EasyExcel.writerSheet("登记明细导出数据").head(headList).build(); |
| | | excelWriter.write(datalist, writeSheet); |
| | | excelWriter.finish(); |
| | | File file = new File(fileName); |
| | | inputStream = new FileInputStream(file); |
| | | sftp.uploadMore(ftpUrl, name, inputStream); |
| | | sftp.logout(); |
| | | inputStream.close(); |
| | | String absolutePath = file.getAbsolutePath(); |
| | | boolean delete = file.delete(); |
| | | log.info("删除excel【{}】结果【{}】", absolutePath, delete); |
| | | } |
| | | |
| | | |
| | | WriteCellStyle headWriteCellStyle = new WriteCellStyle(); |
| | | //设置头居中 |
| | | headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER); |
| | | //设置头字体 |
| | | WriteFont headWriteFont = new WriteFont(); |
| | | headWriteFont.setFontHeightInPoints((short)6); |
| | | headWriteFont.setBold(true); |
| | | headWriteCellStyle.setWriteFont(headWriteFont); |
| | | |
| | | |
| | | WriteCellStyle contentWriteCellStyle = new WriteCellStyle(); |
| | | //设置表格内容字体 |
| | | WriteFont writeFont = new WriteFont(); |
| | | writeFont.setFontHeightInPoints((short)6); |
| | | //设置 水平居中 |
| | | contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER); |
| | | //设置 垂直居中 |
| | | contentWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER); |
| | | contentWriteCellStyle.setWriteFont(writeFont); |
| | | |
| | | contentWriteCellStyle.setWrapped(true); |
| | | HorizontalCellStyleStrategy horizontalCellStyleStrategy = |
| | | new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle); |
| | | |
| | | |
| | | excelWriter = EasyExcel.write(fileName) |
| | | .registerWriteHandler(horizontalCellStyleStrategy).registerWriteHandler(new Custemhandler()) |
| | | .registerWriteHandler(new CustomSheetWriteHandler()).build(); |
| | | WriteSheet writeSheet = EasyExcel.writerSheet("登记明细导出数据").head(headList).build(); |
| | | excelWriter.write(datalist, writeSheet); |
| | | excelWriter.finish(); |
| | | File file = new File(fileName); |
| | | inputStream = new FileInputStream(file); |
| | | sftp.uploadMore(ftpUrl, name, inputStream); |
| | | sftp.logout(); |
| | | inputStream.close(); |
| | | String absolutePath = file.getAbsolutePath(); |
| | | boolean delete = file.delete(); |
| | | log.info("删除excel【{}】结果【{}】", absolutePath, delete); |
| | | } finally { |
| | | // 千万别忘记finish 会帮忙关闭流 |
| | | if (inputStream != null) { |