接在上次文章说的excel的下载,这次说明excel的导入,既然是导入肯定要涉及到文件的上传,下面代码的环境是spingMVC环境,若需使用下面代码,请配置spring环境
1.maven中导入依赖包
<dependency><!-- excel2003 -->
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.8</version>5
</dependency>
<dependency><!-- excel2007以上 -->
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.8</version>
</dependency>
2.代码
@RequestMapping("doImport")
public String doImport(@RequestParam("files[]") MultipartFile file, HttpServletRequest request, HttpServletResponse response)