| | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.annotation.Excel; |
| | | import lombok.Data; |
| | | import org.apache.poi.ss.usermodel.IndexedColors; |
| | | |
| | | import java.util.Date; |
| | | |
| | |
| | | public class DocumentMaterialsVo { |
| | | |
| | | |
| | | @Excel(name="序号", height = 10,width=10) |
| | | @Excel(name="序号", height = 10,width=8,headerColor = IndexedColors.RED, headerBackgroundColor = IndexedColors.WHITE) |
| | | private Long num; |
| | | @Excel(name = "文件编号", height = 10, width=15) |
| | | @Excel(name = "文件编号", height = 10, width=8,headerColor = IndexedColors.BLACK, headerBackgroundColor = IndexedColors.WHITE) |
| | | private String documentNumber; |
| | | @Excel(name = "责任者", height = 10, width=10) |
| | | @Excel(name = "责任者", height = 10, width=8,headerColor = IndexedColors.BLACK, headerBackgroundColor = IndexedColors.WHITE) |
| | | private String creator; |
| | | @Excel(name = "文件题名", height = 20) |
| | | @Excel(name = "文件题名", height = 8,headerColor = IndexedColors.RED, headerBackgroundColor = IndexedColors.WHITE) |
| | | |
| | | private String title; |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | |
| | | @Excel(name = "日期", width = 10, dateFormat = "yyyy-MM-dd", height = 10) |
| | | @Excel(name = "日期", width = 10, dateFormat = "yyyy-MM-dd", height = 10,headerColor = IndexedColors.BLACK, headerBackgroundColor = IndexedColors.WHITE) |
| | | |
| | | private Date date; |
| | | @Excel(name = "页号", height = 10,width = 10) |
| | | @Excel(name = "页号", height = 10,width = 10,headerColor = IndexedColors.RED, headerBackgroundColor = IndexedColors.WHITE) |
| | | |
| | | private Long pageNumber; |
| | | @Excel(name = "备注", height = 20) |
| | | @Excel(name = "备注", height = 20,width=10,headerColor = IndexedColors.BLACK, headerBackgroundColor = IndexedColors.WHITE) |
| | | private String remarks; |
| | | |
| | | @Excel(name = "档号", height = 10) |
| | | @Excel(name = "档号", height = 10,width=10,headerColor = IndexedColors.RED, headerBackgroundColor = IndexedColors.WHITE, headerFontName = "Arial", headerFontBold = true) |
| | | private String recordId; |
| | | @Excel(name = "公开属性", height = 10) |
| | | @Excel(name = "公开属性", height = 10,width=10,headerColor = IndexedColors.BLACK, headerBackgroundColor = IndexedColors.WHITE) |
| | | private String publicity; |
| | | |
| | | |
| | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.annotation.Excel; |
| | | import lombok.Data; |
| | | import org.apache.poi.ss.usermodel.IndexedColors; |
| | | |
| | | import java.util.Date; |
| | | |
| | |
| | | public class DocumentMaterialsVoSmall { |
| | | |
| | | |
| | | @Excel(name="序号") |
| | | @Excel(name="序号",width = 5, headerColor = IndexedColors.BLACK, headerFontBold = true) |
| | | private Long num; |
| | | @Excel(name = "文件编号") |
| | | @Excel(name = "文件编号",width = 10, headerColor = IndexedColors.BLACK, headerFontBold = true) |
| | | private String documentNumber; |
| | | @Excel(name = "编任者") |
| | | @Excel(name = "责任者",width = 10, headerColor = IndexedColors.BLACK, headerFontBold = true) |
| | | private String creator; |
| | | @Excel(name = "文件题名") |
| | | @Excel(name = "文件题名",width = 36, headerColor = IndexedColors.BLACK, headerFontBold = true) |
| | | |
| | | private String title; |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | |
| | | @Excel(name = "日期", width = 30, dateFormat = "yyyy-MM-dd") |
| | | @Excel(name = "日期", width = 12, dateFormat = "yyyy-MM-dd", headerColor = IndexedColors.BLACK, headerFontBold = true) |
| | | |
| | | private Date date; |
| | | @Excel(name = "页号") |
| | | @Excel(name = "页号",width = 10, headerColor = IndexedColors.BLACK, headerFontBold = true) |
| | | |
| | | private Long pageNumber; |
| | | @Excel(name = "备注") |
| | | @Excel(name = "备注",width = 10, headerColor = IndexedColors.BLACK, headerFontBold = true) |
| | | private String remarks; |
| | | |
| | | public DocumentMaterialsVoSmall(Long num, String documentNumber, String creator, String title, Date date, Long pageNumber, String remarks) { |
| | |
| | | public IndexedColors headerColor() default IndexedColors.WHITE; |
| | | |
| | | /** |
| | | * 导出列头字体名称 |
| | | */ |
| | | public String headerFontName() default "Arial"; |
| | | |
| | | /** |
| | | * 导出列头字体是否加粗 |
| | | */ |
| | | public boolean headerFontBold() default false; |
| | | |
| | | /** |
| | | * 导出单元格背景颜色 |
| | | */ |
| | | public IndexedColors backgroundColor() default IndexedColors.WHITE; |
| | |
| | | style.cloneStyleFrom(styles.get("data")); |
| | | style.setAlignment(HorizontalAlignment.CENTER); |
| | | style.setVerticalAlignment(VerticalAlignment.CENTER); |
| | | style.setFillForegroundColor(excel.headerBackgroundColor().index); |
| | | style.setFillPattern(FillPatternType.SOLID_FOREGROUND); |
| | | // 已注释,表头不显示背景色 |
| | | // style.setFillForegroundColor(excel.headerBackgroundColor().index); |
| | | // style.setFillPattern(FillPatternType.SOLID_FOREGROUND); |
| | | // 设置表头自动换行 |
| | | style.setWrapText(true); |
| | | Font headerFont = wb.createFont(); |
| | |
| | | |
| | | // 创建行并设置高度 |
| | | row = sheet.createRow(0); |
| | | row.setHeight((short)(40 * 40)); |
| | | row.setHeight((short)(30 *30)); |
| | | |
| | | // 创建单元格并添加图片 |
| | | Cell cell = row.createCell(0); |
| | |
| | | ClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 0, (short) cell.getColumnIndex(), cell.getRow().getRowNum(), (short) (cell.getColumnIndex() + 5), |
| | | cell.getRow().getRowNum() + 1); |
| | | // 计算居中位置 |
| | | int col1 = 1; // 中间列 |
| | | int col2 = col1 + 5; |
| | | int col1 = 3; // 中间列 |
| | | int col2 = col1 + 2; |
| | | anchor.setCol1(col1); |
| | | anchor.setCol2(col2); |
| | | anchor.setRow1(0); |
| | |
| | | row = sheet.createRow(1); |
| | | sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 6)); |
| | | Cell titleCell = row.createCell(0); |
| | | titleCell.setCellValue("卷内目录"); |
| | | // 设置加粗和居中样式 |
| | | titleCell.setCellValue("卷 内 目 录"); |
| | | // 设置加粗、宋体、18号字体和居中样式 |
| | | CellStyle style = wb.createCellStyle(); |
| | | Font font = wb.createFont(); |
| | | font.setBold(true); |
| | | font.setFontName("宋体"); |
| | | font.setFontHeightInPoints((short) 18); |
| | | style.setFont(font); |
| | | style.setAlignment(HorizontalAlignment.CENTER); |
| | | titleCell.setCellStyle(style); |
| | |
| | | style.setFont(dataFont); |
| | | styles.put("data", style); |
| | | |
| | | style = wb.createCellStyle(); |
| | | style.cloneStyleFrom(styles.get("data")); |
| | | style.setAlignment(HorizontalAlignment.CENTER); |
| | | style.setVerticalAlignment(VerticalAlignment.CENTER); |
| | | style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex()); |
| | | style.setFillPattern(FillPatternType.SOLID_FOREGROUND); |
| | | Font headerFont = wb.createFont(); |
| | | headerFont.setFontName("Arial"); |
| | | headerFont.setFontHeightInPoints((short) 10); |
| | | headerFont.setBold(true); |
| | | headerFont.setColor(IndexedColors.WHITE.getIndex()); |
| | | style.setFont(headerFont); |
| | | // 表头也设置自动换行 |
| | | style.setWrapText(true); |
| | | styles.put("header", style); |
| | | // 创建表头样式映射,根据Excel注解动态生成 |
| | | Map<String, CellStyle> headerStyles = new HashMap<String, CellStyle>(); |
| | | for (Object[] os : fields) |
| | | { |
| | | Excel excel = (Excel) os[1]; |
| | | String key = StringUtils.format("header_{}_{}_{}_{}", excel.headerColor(), excel.headerBackgroundColor(), excel.headerFontName(), excel.headerFontBold()); |
| | | if (!headerStyles.containsKey(key)) |
| | | { |
| | | style = wb.createCellStyle(); |
| | | style.cloneStyleFrom(styles.get("data")); |
| | | style.setAlignment(HorizontalAlignment.CENTER); |
| | | style.setVerticalAlignment(VerticalAlignment.CENTER); |
| | | // 根据注解设置表头背景色 - 已注释,表头不显示背景色 |
| | | /*if (excel.headerBackgroundColor() != IndexedColors.WHITE) { |
| | | style.setFillForegroundColor(excel.headerBackgroundColor().index); |
| | | style.setFillPattern(FillPatternType.SOLID_FOREGROUND); |
| | | }*/ |
| | | // 设置表头自动换行 |
| | | style.setWrapText(true); |
| | | Font headerFont = wb.createFont(); |
| | | headerFont.setFontName(excel.headerFontName()); |
| | | headerFont.setFontHeightInPoints((short) 10); |
| | | headerFont.setBold(excel.headerFontBold()); |
| | | headerFont.setColor(excel.headerColor().index); |
| | | style.setFont(headerFont); |
| | | headerStyles.put(key, style); |
| | | } |
| | | } |
| | | styles.putAll(headerStyles); |
| | | |
| | | style = wb.createCellStyle(); |
| | | style.setAlignment(HorizontalAlignment.CENTER); |
| | |
| | | // 写入列信息 |
| | | cell.setCellValue(attr.name()); |
| | | setDataValidation(attr, row, column); |
| | | cell.setCellStyle(styles.get("header")); |
| | | // 根据Excel注解动态选择表头样式 |
| | | String key = StringUtils.format("header_{}_{}_{}_{}", attr.headerColor(), attr.headerBackgroundColor(), attr.headerFontName(), attr.headerFontBold()); |
| | | cell.setCellStyle(styles.get(key)); |
| | | return cell; |
| | | } |
| | | |
| | |
| | | style.setFont(dataFont); |
| | | styles.put("data", style); |
| | | |
| | | style = wb.createCellStyle(); |
| | | style.cloneStyleFrom(styles.get("data")); |
| | | style.setAlignment(HorizontalAlignment.CENTER); |
| | | style.setVerticalAlignment(VerticalAlignment.CENTER); |
| | | // 设置单元格内容自动换行 |
| | | style.setWrapText(true); |
| | | style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex()); |
| | | style.setFillPattern(FillPatternType.SOLID_FOREGROUND); |
| | | Font headerFont = wb.createFont(); |
| | | headerFont.setFontName("Arial"); |
| | | headerFont.setFontHeightInPoints((short) 10); |
| | | headerFont.setBold(true); |
| | | headerFont.setColor(IndexedColors.WHITE.getIndex()); |
| | | style.setFont(headerFont); |
| | | styles.put("header", style); |
| | | // 创建表头样式映射,根据Excel注解动态生成 |
| | | Map<String, CellStyle> headerStyles = new HashMap<String, CellStyle>(); |
| | | for (Object[] os : fields) |
| | | { |
| | | Excel excel = (Excel) os[1]; |
| | | String key = StringUtils.format("header_{}_{}", excel.headerColor(), excel.headerBackgroundColor()); |
| | | if (!headerStyles.containsKey(key)) |
| | | { |
| | | style = wb.createCellStyle(); |
| | | style.cloneStyleFrom(styles.get("data")); |
| | | style.setAlignment(HorizontalAlignment.CENTER); |
| | | style.setVerticalAlignment(VerticalAlignment.CENTER); |
| | | // 设置单元格内容自动换行 |
| | | style.setWrapText(true); |
| | | // 根据注解设置表头背景色 - 已注释,表头不显示背景色 |
| | | /*if (excel.headerBackgroundColor() != IndexedColors.WHITE) { |
| | | style.setFillForegroundColor(excel.headerBackgroundColor().index); |
| | | style.setFillPattern(FillPatternType.SOLID_FOREGROUND); |
| | | }*/ |
| | | Font headerFont = wb.createFont(); |
| | | headerFont.setFontName("Arial"); |
| | | headerFont.setFontHeightInPoints((short) 10); |
| | | headerFont.setBold(false); |
| | | headerFont.setColor(excel.headerColor().index); |
| | | style.setFont(headerFont); |
| | | headerStyles.put(key, style); |
| | | } |
| | | } |
| | | styles.putAll(headerStyles); |
| | | |
| | | style = wb.createCellStyle(); |
| | | style.setAlignment(HorizontalAlignment.CENTER); |
| | |
| | | // 写入列信息 |
| | | cell.setCellValue(attr.name()); |
| | | setDataValidation(attr, row, column); |
| | | cell.setCellStyle(styles.get("header")); |
| | | // 根据Excel注解动态选择表头样式 |
| | | String key = StringUtils.format("header_{}_{}", attr.headerColor(), attr.headerBackgroundColor()); |
| | | cell.setCellStyle(styles.get(key)); |
| | | return cell; |
| | | } |
| | | |
| | |
| | | style.setFont(dataFont); |
| | | styles.put("data", style); |
| | | |
| | | style = wb.createCellStyle(); |
| | | style.cloneStyleFrom(styles.get("data")); |
| | | style.setAlignment(HorizontalAlignment.CENTER); |
| | | style.setVerticalAlignment(VerticalAlignment.CENTER); |
| | | // 设置单元格内容自动换行 |
| | | style.setWrapText(true); |
| | | style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex()); |
| | | style.setFillPattern(FillPatternType.SOLID_FOREGROUND); |
| | | Font headerFont = wb.createFont(); |
| | | headerFont.setFontName("Arial"); |
| | | headerFont.setFontHeightInPoints((short) 10); |
| | | headerFont.setBold(true); |
| | | headerFont.setColor(IndexedColors.WHITE.getIndex()); |
| | | style.setFont(headerFont); |
| | | styles.put("header", style); |
| | | // 创建表头样式映射,根据Excel注解动态生成 |
| | | Map<String, CellStyle> headerStyles = new HashMap<String, CellStyle>(); |
| | | for (Object[] os : fields) |
| | | { |
| | | Excel excel = (Excel) os[1]; |
| | | String key = StringUtils.format("header_{}_{}", excel.headerColor(), excel.headerBackgroundColor()); |
| | | if (!headerStyles.containsKey(key)) |
| | | { |
| | | style = wb.createCellStyle(); |
| | | style.cloneStyleFrom(styles.get("data")); |
| | | style.setAlignment(HorizontalAlignment.CENTER); |
| | | style.setVerticalAlignment(VerticalAlignment.CENTER); |
| | | // 设置单元格内容自动换行 |
| | | style.setWrapText(true); |
| | | // 根据注解设置表头背景色 - 已注释,表头不显示背景色 |
| | | /*if (excel.headerBackgroundColor() != IndexedColors.WHITE) { |
| | | style.setFillForegroundColor(excel.headerBackgroundColor().index); |
| | | style.setFillPattern(FillPatternType.SOLID_FOREGROUND); |
| | | }*/ |
| | | Font headerFont = wb.createFont(); |
| | | headerFont.setFontName("Arial"); |
| | | headerFont.setFontHeightInPoints((short) 10); |
| | | headerFont.setBold(excel.headerFontBold()); |
| | | headerFont.setColor(excel.headerColor().index); |
| | | style.setFont(headerFont); |
| | | headerStyles.put(key, style); |
| | | } |
| | | } |
| | | styles.putAll(headerStyles); |
| | | |
| | | style = wb.createCellStyle(); |
| | | style.setAlignment(HorizontalAlignment.CENTER); |
| | |
| | | // 写入列信息 |
| | | cell.setCellValue(attr.name()); |
| | | setDataValidation(attr, row, column); |
| | | cell.setCellStyle(styles.get("header")); |
| | | // 根据Excel注解动态选择表头样式 |
| | | String key = StringUtils.format("header_{}_{}", attr.headerColor(), attr.headerBackgroundColor()); |
| | | cell.setCellStyle(styles.get(key)); |
| | | return cell; |
| | | } |
| | | |
| | |
| | | style.setFont(dataFont); |
| | | styles.put("data", style); |
| | | |
| | | style = wb.createCellStyle(); |
| | | style.cloneStyleFrom(styles.get("data")); |
| | | style.setAlignment(HorizontalAlignment.CENTER); |
| | | style.setVerticalAlignment(VerticalAlignment.CENTER); |
| | | // 设置单元格内容自动换行 |
| | | style.setWrapText(true); |
| | | style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex()); |
| | | style.setFillPattern(FillPatternType.SOLID_FOREGROUND); |
| | | Font headerFont = wb.createFont(); |
| | | headerFont.setFontName("Arial"); |
| | | headerFont.setFontHeightInPoints((short) 10); |
| | | headerFont.setBold(true); |
| | | headerFont.setColor(IndexedColors.WHITE.getIndex()); |
| | | style.setFont(headerFont); |
| | | styles.put("header", style); |
| | | // 创建表头样式映射,根据Excel注解动态生成 |
| | | Map<String, CellStyle> headerStyles = new HashMap<String, CellStyle>(); |
| | | for (Object[] os : fields) |
| | | { |
| | | Excel excel = (Excel) os[1]; |
| | | String key = StringUtils.format("header_{}_{}", excel.headerColor(), excel.headerBackgroundColor()); |
| | | if (!headerStyles.containsKey(key)) |
| | | { |
| | | style = wb.createCellStyle(); |
| | | style.cloneStyleFrom(styles.get("data")); |
| | | style.setAlignment(HorizontalAlignment.CENTER); |
| | | style.setVerticalAlignment(VerticalAlignment.CENTER); |
| | | // 设置单元格内容自动换行 |
| | | style.setWrapText(true); |
| | | // 根据注解设置表头背景色 - 已注释,表头不显示背景色 |
| | | /*if (excel.headerBackgroundColor() != IndexedColors.WHITE) { |
| | | style.setFillForegroundColor(excel.headerBackgroundColor().index); |
| | | style.setFillPattern(FillPatternType.SOLID_FOREGROUND); |
| | | }*/ |
| | | Font headerFont = wb.createFont(); |
| | | headerFont.setFontName("Arial"); |
| | | headerFont.setFontHeightInPoints((short) 10); |
| | | headerFont.setBold(false); |
| | | headerFont.setColor(excel.headerColor().index); |
| | | style.setFont(headerFont); |
| | | headerStyles.put(key, style); |
| | | } |
| | | } |
| | | styles.putAll(headerStyles); |
| | | |
| | | style = wb.createCellStyle(); |
| | | style.setAlignment(HorizontalAlignment.CENTER); |
| | |
| | | // 写入列信息 |
| | | cell.setCellValue(attr.name()); |
| | | setDataValidation(attr, row, column); |
| | | cell.setCellStyle(styles.get("header")); |
| | | // 根据Excel注解动态选择表头样式 |
| | | String key = StringUtils.format("header_{}_{}", attr.headerColor(), attr.headerBackgroundColor()); |
| | | cell.setCellStyle(styles.get(key)); |
| | | return cell; |
| | | } |
| | | |