<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.4.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.example.yan</groupId> <artifactId>excel_split</artifactId> <version>0.0.1-SNAPSHOT</version> <name>excel_split</name> <description>Demo project for Spring Boot</description> <properties> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency> <!-- <dependency>--> <!-- <groupId>org.springframework.boot</groupId>--> <!-- <artifactId>spring-boot-starter-security</artifactId>--> <!-- </dependency>--> <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <!-- <version>5.7.14</version>--> <version>4.6.1</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>3.17</version> <!-- <version>5.0.0</version>--> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- <dependency>--> <!-- <groupId>net.sf.json-lib</groupId>--> <!-- <artifactId>json-lib</artifactId>--> <!-- <version>2.4</version>--> <!-- <classifier>jdk15</classifier>--> <!-- </dependency>--> <!--alibaba Json--> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.47</version> </dependency> <!-- <dependency>--> <!-- <groupId>org.thymeleaf.extras</groupId>--> <!-- <artifactId>thymeleaf-extras-springsecurity5</artifactId>--> <!-- </dependency>--> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <!-- <dependency>--> <!-- <groupId>org.springframework.security</groupId>--> <!-- <artifactId>spring-security-test</artifactId>--> <!-- <scope>test</scope>--> <!-- </dependency>--> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <excludes> <exclude> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </exclude> </excludes> </configuration> </plugin> </plugins> </build> </project>
pom的依赖很重要 利用 hutool和poi的版本进行的
package com.example.yan.excel_split.controller; import cn.hutool.poi.excel.ExcelReader; import cn.hutool.poi.excel.ExcelUtil; import com.alibaba.fastjson.JSON; import java.util.List; public class test1 { public static void main(String[] args) { ExcelReader fileReader = ExcelUtil.getReader("C:\\Users\\75763\\Desktop\\SHOP.105110000000005.20211013.02.success(1).xls"); List<List<Object>> readAll = fileReader.read(); for (List<Object> object : readAll) { System.out.println(JSON.toJSONString(object)); } } }
多条重复语句就会显示为空 字符串;
希望可以解决大家的一些问题;