1.开发背景
在web项目中,经常会需要查询数据导出excel,以前比较常见的就是用poi。使用poi的时候也有两种方式,一种就是直接将集合一次性导出为excel,还有一种是分批次追加的方式适合数据量较大的情况。poi支持xls和xlsx,使用2003版本的只支持6万多行以下的数据量,使用2007版本的支持百万行。但是呢,当数据量大了之后这种方式却非常耗内存和时间。
接触了etl之后就想着用kettle来做导数据,经过测试是完全可行的。几十万行,一百万行都能快速导出来,代码也非常简单。
2.kettle相关maven依赖如下
1 <dependency> 2 <groupId>org.apache.commons</groupId> 3 <artifactId>commons-vfs2</artifactId> 4 <version>2.0</version> 5 </dependency> 6 <dependency> 7 <groupId>org.scannotation</groupId> 8 <artifactId>scannotation</artifactId> 9 <version>1.0.3</version> 10 </dependency> 11 <dependency> 12 <groupId>dom4j</groupId> 13 <artifactId>dom4j</artifactId> 14 <version>1.6.1</version> 15 </dependency> 16 <dependency> 17 <groupId>pentaho-kettle</groupId> 18 <artifactId>kettle-vfs</artifactId> 19 <version>5.2.0.0</version> 20 <classifier>pentaho</classifier> 21 </dependency> 22 <dependency> 23 <groupId>pentaho-kettle</groupId> 24 <artifactId>kettle-engine</artifactId> 25 <version>5.2.0.0</version> 26 </dependency> 27 <dependency> 28 <groupId>pentaho-kettle</groupId> 29 <artifactId>kettle-core</artifactId> 30 <version>5.2.0.0</version> 31 </dependency>
仓库如果没有kettle的jar包,可以先现在下来再上传到maven仓库
3.ktr文件:如以下附件下载链接