如何解决JXLS对象集合样本不起作用
我正在尝试使用最新版本的 JXLS 从 Java 7 中的ArrayList生成XLS。
我不知道为什么它没有给出期望的输出。
Excel模板
输出Excel
Output Excel after below code gets run
所以输出等于模板内容。
Maven
<dependencies>
<dependency>
<groupId>org.jxls</groupId>
<artifactId>jxls</artifactId>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>org.jxls</groupId>
<artifactId>jxls-poi</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.jxls</groupId>
<artifactId>jxls-reader</artifactId>
<version>2.0.6</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
JAVA
List<Employee> employees = new ArrayList();
Employee employee = new Employee();
employee.setName("Employee name");
employees.add(employee);
try(InputStream is = new FileInputStream("D:\\template.xlsx")) {
try (OutputStream os = new FileOutputStream("D:\\output.xlsx")) {
Context context = new Context();
context.putVar("employees",employees);
JxlsHelper.getInstance().processTemplate(is,os,context);
}
}
链接: Referred link
注意:在控制台上没有错误
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。