平时经常遇到客户要帮忙导入一些数据到数据库中,有些数据比较多有时候手动录入就会很耗时间,所以就自己写一个Excel导入的demo记录一下我对EasyPOI的误区;本文使用SpringBoot2.0,EasyPOI

开发框架

框架:SpringBoot2.0
java jdk 1.8
开发工具:Eclipse
数据库:Orcal

一.首先在pom.xml中导入EasyPOI的架包

pom.xml的主要文件信息如下:

<!-- 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

Controller:

/**   
 * @author lr
 * @date 20181226下午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 

相关文章: