功能描述
有的时候需要生成excel文件 对单元格填的值进行校验符不符合规则。
这里给出的例子是 excel中填充下拉框选项,如果输入的值不符合下拉框选项 则弹出提示
maven依赖
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-spring-boot-starter</artifactId>
<version>4.4.0</version>
</dependency>
controller内方法
@GetMapping("/down")
public void downTemplate(HttpServletResponse response) throws IOException {
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
String fileName = URLEncoder.encode("FileName", "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;fi