public class TestEasyExcel {
public static void main(String[] args) throws Exception {
String filepath = "D:/LDT/测试easyExcel.xlsx";
Sheet sheet = new Sheet(1, 0);
sheet.setSheetName("xxxx");
List<List<String>> header = new ArrayList<List<String>>();
header.add(Lists.newArrayList("Number"));
header.add(Lists.newArrayList("Name"));
header.add(Lists.newArrayList("Age"));
sheet.setHead(header);
List<List<Object>> data = new ArrayList<List<Object>>();
data.add(Lists.newArrayList("1001","Zhangsan",13));
data.add(Lists.newArrayList("1002","Lisi",23));
data.add(Lists.newArrayList("1003","Wangwu",33));
OutputStream out = new FileOutputStream(new File(filepath));
ExcelWriter writer = EasyExcelFactory.getWriter(out, ExcelTypeEnum.XLSX, true);
System.out.println(writer);
writer.write1(data, sheet);
writer.finish();
}
}
Error message: org.apache.poi.ss.usermodel.font.setbold (z) V
Cause: there is a conflict between Maven version and poi jar package. The following is Maven version. If POI version is 3.8 or 3.9, this exception message will appear.
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>1.1.2-beta4</version>
</dependency>
Solution: this exception will not occur in version 3.17 and above.
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.1</version>
</dependency>
Read More:
- [Solved] org.apache.maven.archiver.MavenArchiver.getManifest(org.apache.maven.project.MavenProject…
- Java will convert Excel to list set or JSON, export excel file to local, excel import and export, easyexcel tool class
- How to Solve EasyExcel3.0.5 Version Error
- JAVA: How to use the third-party font library method (using the third-party TTF / TTC font library method)
- [Solved] java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]
- [Solved] SpringBoot Pack Project: Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources
- [Solved] Mybatis add dependencies Error: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration.
- [Solved] write javaBean error, fastjson version 1.2.76, class org.apache.flink.table.data.binary
- [Solved] Spring Boot Package Error: Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0
- [Solved] O2oa compile error: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin
- [Solved] Java POI export error: Invalid row number (65536) outside allowable range
- [Solved] Java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileItemFactory
- [Solved] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install (default-cli) on
- [Solved] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:3.1.1:analyze-only
- [Solved] Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration
- Springboot Project Error: Failed to execute goal org.apache.maven.plugins
- [Solved] org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSession…
- [Solved] JSP tag forwarding forword error: org.apache.jasper.JasperException
- [Solved] org.apache.flink.client.program.ProgramInvocationException: The main method caused an error
- [Solved] Java POI Operate Excel error NullPointException