用能空调代码提交 终端相关代码修改
This commit is contained in:
@@ -5,7 +5,11 @@ import cn.afterturn.easypoi.excel.entity.ExportParams;
|
|||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
import com.njcn.web.utils.HttpServletUtil;
|
import com.njcn.web.utils.HttpServletUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.poi.hssf.usermodel.DVConstraint;
|
||||||
|
import org.apache.poi.hssf.usermodel.HSSFDataValidation;
|
||||||
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
import org.apache.poi.ss.usermodel.Workbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
|
import org.apache.poi.ss.util.CellRangeAddressList;
|
||||||
|
|
||||||
import javax.servlet.ServletOutputStream;
|
import javax.servlet.ServletOutputStream;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
@@ -80,4 +84,27 @@ public class ExcelUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* firstRow 開始行號 根据此项目,默认为2(下标0开始)
|
||||||
|
* lastRow 根据此项目,默认为最大65535
|
||||||
|
* @param firstCol 区域中第一个单元格的列号 (下标0开始)
|
||||||
|
* @param lastCol 区域中最后一个单元格的列号
|
||||||
|
* @param strings 下拉内容
|
||||||
|
* */
|
||||||
|
public static void selectList(Workbook workbook,int firstCol,int lastCol,String[] strings ){
|
||||||
|
|
||||||
|
Sheet sheet = workbook.getSheetAt(0);
|
||||||
|
// 生成下拉列表
|
||||||
|
// 只对(x,x)单元格有效
|
||||||
|
CellRangeAddressList cellRangeAddressList = new CellRangeAddressList(3, 65535, firstCol, lastCol);
|
||||||
|
// 生成下拉框内容
|
||||||
|
DVConstraint dvConstraint = DVConstraint.createExplicitListConstraint(strings);
|
||||||
|
HSSFDataValidation dataValidation = new HSSFDataValidation(cellRangeAddressList, dvConstraint);
|
||||||
|
// 对sheet页生效
|
||||||
|
sheet.addValidationData(dataValidation);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user