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/PEXCustomSheetWriteHandler.java | 16 +++++++++------- 1 files changed, 9 insertions(+), 7 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/excel/PEXCustomSheetWriteHandler.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/excel/PEXCustomSheetWriteHandler.java index ebc4d3d..ac51499 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/excel/PEXCustomSheetWriteHandler.java +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/excel/PEXCustomSheetWriteHandler.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,15 +31,16 @@ // 区间设置 第一列第一行和第二行的数据。由于第一行是头,所以第一、二行的数据实际上是第二三行 CellRangeAddressList cellRangeAddressList1 = new CellRangeAddressList(1, 5000, 3, 3); - CellRangeAddressList cellRangeAddressList2 = new CellRangeAddressList(1, 5000, 4 ,4); - CellRangeAddressList cellRangeAddressList3 = new CellRangeAddressList(1, 5000, 25 ,25); + CellRangeAddressList cellRangeAddressList2 = new CellRangeAddressList(1, 5000, 4, 4); + CellRangeAddressList cellRangeAddressList3 = new CellRangeAddressList(1, 5000, 25, 25); DataValidationHelper helper = writeSheetHolder.getSheet().getDataValidationHelper(); - DataValidationConstraint constraint1 = helper.createExplicitListConstraint(new String[] {"中共党员","中共预备党员","共青团员","民革党员","民盟盟员","民建会员","农工党党员","致公党党员","九三学社社员","台盟盟员","无党派人士","群众"}); + DataValidationConstraint constraint1 = helper.createExplicitListConstraint(new String[] {"中共党员", "中共预备党员", + "共青团员", "民革党员", "民盟盟员", "民建会员", "农工党党员", "致公党党员", "九三学社社员", "台盟盟员", "无党派人士", "群众"}); DataValidationConstraint constraint2 = helper.createExplicitListConstraint(new String[] {"是", "否"}); DataValidationConstraint constraint3 = helper.createExplicitListConstraint(new String[] {"本地", "外地"}); DataValidation dataValidation1 = helper.createValidation(constraint1, cellRangeAddressList1); DataValidation dataValidation2 = helper.createValidation(constraint2, cellRangeAddressList2); - DataValidation dataValidation3= helper.createValidation(constraint3, cellRangeAddressList3); + DataValidation dataValidation3 = helper.createValidation(constraint3, cellRangeAddressList3); writeSheetHolder.getSheet().addValidationData(dataValidation1); writeSheetHolder.getSheet().addValidationData(dataValidation2); -- Gitblit v1.7.1