From 177249c76aeea0b4bf8d8816d4994e3b445b45ce Mon Sep 17 00:00:00 2001 From: huanghongfa <huanghongfa123456> Date: 星期四, 02 九月 2021 10:39:34 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/zzj' into zzj --- springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/excel/CustomSheetWriteHandler.java | 30 +++++++++++++++++------------- 1 files changed, 17 insertions(+), 13 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/excel/CustomSheetWriteHandler.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/excel/CustomSheetWriteHandler.java index 526b10e..c1e13f9 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/excel/CustomSheetWriteHandler.java +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/excel/CustomSheetWriteHandler.java @@ -1,14 +1,15 @@ package com.panzhihua.common.excel; -import com.alibaba.excel.write.handler.SheetWriteHandler; -import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; -import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder; import org.apache.poi.ss.usermodel.DataValidation; import org.apache.poi.ss.usermodel.DataValidationConstraint; import org.apache.poi.ss.usermodel.DataValidationHelper; import org.apache.poi.ss.util.CellRangeAddressList; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + +import com.alibaba.excel.write.handler.SheetWriteHandler; +import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; +import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder; /** * 自定义拦截器.对第一列第一行和第二行的数据新增下拉框,显示 测试1 测试2 @@ -30,21 +31,24 @@ // 区间设置 第一列第一行和第二行的数据。由于第一行是头,所以第一、二行的数据实际上是第二三行 CellRangeAddressList cellRangeAddressList = new CellRangeAddressList(1, 2000, 11, 11); - CellRangeAddressList cellRangeAddressList1 = new CellRangeAddressList(1, 2000, 4 ,4); - CellRangeAddressList cellRangeAddressList2 = new CellRangeAddressList(1, 2000, 6 ,6); - CellRangeAddressList cellRangeAddressList3 = new CellRangeAddressList(1, 2000, 13 ,13); - CellRangeAddressList cellRangeAddressList4 = new CellRangeAddressList(1, 2000, 14 ,14); + CellRangeAddressList cellRangeAddressList1 = new CellRangeAddressList(1, 2000, 4, 4); + CellRangeAddressList cellRangeAddressList2 = new CellRangeAddressList(1, 2000, 6, 6); + CellRangeAddressList cellRangeAddressList3 = new CellRangeAddressList(1, 2000, 13, 13); + CellRangeAddressList cellRangeAddressList4 = new CellRangeAddressList(1, 2000, 14, 14); DataValidationHelper helper = writeSheetHolder.getSheet().getDataValidationHelper(); - DataValidationConstraint constraint = helper.createExplicitListConstraint(new String[] {"男", "女","未知"}); - DataValidationConstraint constraint1 = helper.createExplicitListConstraint(new String[] {"中共党员","中共预备党员","共青团员","民革党员","民盟盟员","民建会员","农工党党员","致公党党员","九三学社社员","台盟盟员","无党派人士","群众"}); + DataValidationConstraint constraint = helper.createExplicitListConstraint(new String[] {"男", "女", "未知"}); + DataValidationConstraint constraint1 = helper.createExplicitListConstraint(new String[] {"中共党员", "中共预备党员", + "共青团员", "民革党员", "民盟盟员", "民建会员", "农工党党员", "致公党党员", "九三学社社员", "台盟盟员", "无党派人士", "群众"}); DataValidationConstraint constraint2 = helper.createExplicitListConstraint(new String[] {"本地", "外地"}); - DataValidationConstraint constraint3 = helper.createExplicitListConstraint(new String[] {"未婚", "已婚", "初婚", "再婚", "复婚", "丧偶", "离婚", "未说明的婚育状况"}); - DataValidationConstraint constraint4 = helper.createExplicitListConstraint(new String[] {"很好", "较好", "一般", "较差", "很差"}); + DataValidationConstraint constraint3 = + helper.createExplicitListConstraint(new String[] {"未婚", "已婚", "初婚", "再婚", "复婚", "丧偶", "离婚", "未说明的婚育状况"}); + DataValidationConstraint constraint4 = + helper.createExplicitListConstraint(new String[] {"很好", "较好", "一般", "较差", "很差"}); DataValidation dataValidation = helper.createValidation(constraint2, cellRangeAddressList); DataValidation dataValidation1 = helper.createValidation(constraint, cellRangeAddressList1); - DataValidation dataValidation2= helper.createValidation(constraint1, cellRangeAddressList2); + DataValidation dataValidation2 = helper.createValidation(constraint1, cellRangeAddressList2); DataValidation dataValidation3 = helper.createValidation(constraint3, cellRangeAddressList3); - DataValidation dataValidation4= helper.createValidation(constraint4, cellRangeAddressList4); + DataValidation dataValidation4 = helper.createValidation(constraint4, cellRangeAddressList4); writeSheetHolder.getSheet().addValidationData(dataValidation); writeSheetHolder.getSheet().addValidationData(dataValidation1); -- Gitblit v1.7.1