package com.ycl.handler;
|
|
import com.alibaba.excel.write.handler.SheetWriteHandler;
|
import com.alibaba.excel.write.handler.context.SheetWriteHandlerContext;
|
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.usermodel.Sheet;
|
import org.apache.poi.ss.util.CellRangeAddressList;
|
|
/**
|
* @author gonghl
|
* @since 2024/8/26 下午 1:38
|
*/
|
public class ImageResourceHandler implements SheetWriteHandler {
|
|
@Override
|
public void afterSheetCreate(SheetWriteHandlerContext context) {
|
Sheet sheet = context.getWriteSheetHolder().getSheet();
|
// 区域/单位名称
|
CellRangeAddressList cellRangeAddressList3 = new CellRangeAddressList(1, 9999, 1, 1);
|
DataValidationHelper helper3 = context.getWriteSheetHolder().getSheet().getDataValidationHelper();
|
DataValidationConstraint constraint3 = helper3.createExplicitListConstraint(new String[]{"富顺县公安局", "大安区公安局", "自流井区公安局", "贡井区公安局", "荣县公安局", "自贡市公安局", "高新区公安局", "沿滩区公安局"});
|
DataValidation dataValidation3 = helper3.createValidation(constraint3, cellRangeAddressList3);
|
// 报警类型
|
CellRangeAddressList cellRangeAddressList = new CellRangeAddressList(1, 9999, 2, 2);
|
DataValidationHelper helper = context.getWriteSheetHolder().getSheet().getDataValidationHelper();
|
DataValidationConstraint constraint = helper.createExplicitListConstraint(new String[]{"SSH弱口令", "Telnet弱口令", "RDP弱口令", "FTP弱口令", "数据库弱口令"});
|
DataValidation dataValidation = helper.createValidation(constraint, cellRangeAddressList);
|
// 报警级别
|
CellRangeAddressList cellRangeAddressList2 = new CellRangeAddressList(1, 9999, 3, 3);
|
DataValidationHelper helper2 = context.getWriteSheetHolder().getSheet().getDataValidationHelper();
|
DataValidationConstraint constraint2 = helper2.createExplicitListConstraint(new String[]{"低危", "中危", "高危", "超危"});
|
DataValidation dataValidation2 = helper2.createValidation(constraint2, cellRangeAddressList2);
|
sheet.addValidationData(dataValidation);
|
sheet.addValidationData(dataValidation2);
|
sheet.addValidationData(dataValidation3);
|
}
|
|
}
|