diff --git a/springboot-ademo/pom.xml b/springboot-ademo/pom.xml index 47ccde5..dea9520 100644 --- a/springboot-ademo/pom.xml +++ b/springboot-ademo/pom.xml @@ -25,6 +25,12 @@ com.tiesheng.springboot-parent springboot-web + + + com.alibaba + easyexcel + + diff --git a/springboot-ademo/src/main/java/com/tiesheng/demo/controller/TestController.java b/springboot-ademo/src/main/java/com/tiesheng/demo/controller/TestController.java index b18af56..f9286e9 100644 --- a/springboot-ademo/src/main/java/com/tiesheng/demo/controller/TestController.java +++ b/springboot-ademo/src/main/java/com/tiesheng/demo/controller/TestController.java @@ -1,10 +1,17 @@ package com.tiesheng.demo.controller; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.TimeInterval; import cn.hutool.json.JSONUtil; import cn.hutool.log.LogFactory; +import cn.hutool.poi.excel.ExcelUtil; +import cn.hutool.poi.excel.sax.handler.RowHandler; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.read.listener.ReadListener; import com.tiesheng.annotation.token.TokenIgnore; import com.tiesheng.core.service.CoreMessageService; +import com.tiesheng.demo.pojos.PoiBean; import com.tiesheng.demo.pojos.TestFile; import com.tiesheng.login.config.token.TsTokenConfig; import com.tiesheng.login.config.token.bean.TokenBean; @@ -19,6 +26,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletResponse; +import java.io.File; import java.util.List; /** @@ -121,4 +129,43 @@ public class TestController { return ApiResp.respOK(""); } + + @RequestMapping("poi") + @TokenIgnore + public ApiResp poi() { + TimeInterval timeInterval = new TimeInterval(); + + FileUploadPath file = FileUploadPath.file("/upload/test.xlsx"); + + EasyExcel.read(new File(file.getAbsolutePath()), PoiBean.class, new ReadListener() { + + @Override + public void invoke(PoiBean poiBean, AnalysisContext analysisContext) { + + } + + @Override + public void doAfterAllAnalysed(AnalysisContext analysisContext) { + + } + }).sheet().doRead(); + + System.out.println("timeInterval: " + timeInterval.interval()); + return ApiResp.respOK(""); + } + + @RequestMapping("poiTool") + @TokenIgnore + public ApiResp poiTool() { + TimeInterval timeInterval = new TimeInterval(); + + FileUploadPath file = FileUploadPath.file("/upload/test.xlsx"); + + ExcelUtil.getReader(new File(file.getAbsolutePath())).read(); + + System.out.println("timeInterval: " + timeInterval.interval()); + + return ApiResp.respOK(""); + } + } diff --git a/springboot-ademo/src/main/java/com/tiesheng/demo/pojos/PoiBean.java b/springboot-ademo/src/main/java/com/tiesheng/demo/pojos/PoiBean.java new file mode 100644 index 0000000..f02949e --- /dev/null +++ b/springboot-ademo/src/main/java/com/tiesheng/demo/pojos/PoiBean.java @@ -0,0 +1,75 @@ +package com.tiesheng.demo.pojos; + +import com.alibaba.excel.annotation.ExcelProperty; + +public class PoiBean { + + @ExcelProperty("学院") + private String college; + private String type; + private String name; + private String no; + private String sex; + private String fdy; + private String fdyNo; + + /////////////////////////////////////////////////////////////////////////// + // setter\getter + /////////////////////////////////////////////////////////////////////////// + + public String getCollege() { + return college; + } + + public void setCollege(String college) { + this.college = college; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getNo() { + return no; + } + + public void setNo(String no) { + this.no = no; + } + + public String getSex() { + return sex; + } + + public void setSex(String sex) { + this.sex = sex; + } + + public String getFdy() { + return fdy; + } + + public void setFdy(String fdy) { + this.fdy = fdy; + } + + public String getFdyNo() { + return fdyNo; + } + + public void setFdyNo(String fdyNo) { + this.fdyNo = fdyNo; + } +} diff --git a/springboot-ademo/src/main/resources/static/mobile/0.0.13/index.html b/springboot-ademo/src/main/resources/static/mobile/0.0.13/index.html index 451c6cf..4518b06 100644 --- a/springboot-ademo/src/main/resources/static/mobile/0.0.13/index.html +++ b/springboot-ademo/src/main/resources/static/mobile/0.0.13/index.html @@ -7,31 +7,10 @@ content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" /> - 钉钉授权 - - diff --git a/springboot-ademo/src/main/resources/static/mobile/0.0.4/index.html b/springboot-ademo/src/main/resources/static/mobile/0.0.4/index.html index 451c6cf..d05a118 100644 --- a/springboot-ademo/src/main/resources/static/mobile/0.0.4/index.html +++ b/springboot-ademo/src/main/resources/static/mobile/0.0.4/index.html @@ -7,30 +7,10 @@ content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" /> - 钉钉授权 -