平時常常遇到客戶要幫忙導入一些數據到數據庫中,有些數據比較多有時候手動錄入就會很耗時間,因此就本身寫一個Excel導入的demo記錄一下我對EasyPOI的誤區;本文使用
SpringBoot2.0
,EasyPOI
java
框架:SpringBoot2.0
java jdk 1.8
開發工具:Eclipse
數據庫:Orcal
pom.xml的主要文件信息以下:git
<!-- easypoi --> <dependency> <groupId>cn.afterturn</groupId> <artifactId>easypoi-base</artifactId> <version>3.0.3</version> </dependency> <dependency> <groupId>cn.afterturn</groupId> <artifactId>easypoi-web</artifactId> <version>3.0.3</version> </dependency> <dependency> <groupId>cn.afterturn</groupId> <artifactId>easypoi-annotation</artifactId> <version>3.0.3</version> </dependency>
Controller:github
/** * @author lr * @date 2018年12月26日 下午6:51:43 * @version V1.0.0 */ package com.louis.sql.tools.controller; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import com.louis.sql.tools.model.LongHuaAreaDO; import com.louis.sql.tools.result.HttpResult; import com.louis.sql.tools.service.LongHuaAreaService; @RestController @RequestMapping("longhua") public class LongHuaController { @Autowired private LongHuaAreaService longHuaAreaService; /** * @Title: listAllData * @Description: 查詢處全部的數據並展現 * @param @return 參數說明 * @return HttpResult 返回類型 * @throws */ @RequestMapping(value = "/list", method = RequestMethod.GET) public HttpResult listAllData(){ return HttpResult