SpringMVC读取Excel文件

xiaoxiao2021-02-28  70

1.直接读取Excel文件

使用注解接收文件 @RequestParam(value = “excel”, required = true) MultipartFile file 其中value的值是上传文件的文件名;从file读取输入流 从file中获取文件名、文件大小以及输入流等信息; InputStream is = file.getInputStream();使用输入流构造文件 XSSFWorkbook workBook = new XSSFWorkbook(is); 然后对excel文件进行操作。

Demo:

<form action="http://127.0.0.1:8080/file" method="post" enctype="multipart/form-data"> 选择文件:<input type="file" name="excel"> <input type="submit" value="提交"> </form>
转载请注明原文地址: https://www.6miu.com/read-38027.html

最新回复(0)