1.基础功能导出测试
测试用例,导出5行数据,一个关联类,25000或者5W行数据
测试demo
主对象
public
class
MsgClient
implements
java.io.Serializable {
/** id */
private
java.lang.String id;
// 电话号码(主键)
@Excel
(name =
"电话号码"
, width =
20
, orderNum =
"2"
)
private
String clientPhone =
null
;
// 客户姓名
@Excel
(name =
"姓名"
, orderNum =
"1"
)
private
String clientName =
null
;
// 所属分组
@ExcelEntity
private
MsgClientGroup group =
null
;
// 备注
@Excel
(name =
"备注"
)
private
String remark =
null
;
// 生日
@Excel
(name =
"出生日期"
, format =
"yyyy-MM-dd"
, width =
20
)
private
Date birthday =
null
;
// 创建人
private
String createBy =
null
;
public
class
MsgClientGroup
implements
Serializable {
/**
*
*/
private
static
final
long
serialVersionUID = 6946265640897464878L;
// 组名
@Excel
(name =
"分组"
)
private
String groupName =
null
;
/**
* 创建人
*/
private
String createBy;
测试代码
@Test
public
void
test()
throws
Exception {
List<MsgClient> list =
new
ArrayList<MsgClient>();
for
(
int
i =
0
; i <
25000
; i++) {
MsgClient client =
new
MsgClient();
client.setBirthday(
new
Date());
client.setClientName(
"小明"
+ i);
client.setClientPhone(
"18797"
+ i);
client.setCreateBy(
"jueyue"
);
client.setId(
"1"
+ i);
client.setRemark(
"测试"
+ i);
MsgClientGroup group =
new
MsgClientGroup();
group.setGroupName(
"测试"
+ i);
client.setGroup(group);
list.add(client);
}
Date start =
new
Date();
Workbook workbook = ExcelExportUtil.exportExcel(
new
ExportParams(
"2412312"
,
"测试"
),
MsgClient.
class
, list);
System.out.println(
new
Date().getTime() - start.getTime());
File savefile =
new
File(
"d:/"
);
if
(!savefile.exists()) {
savefile.mkdirs();
}
FileOutputStream fos =
new
FileOutputStream(
"d:/tt.xls"
);
workbook.write(fos);
fos.close();
}
导出用时
03版本
测试No |
数据量
|
用时
|
1
|
25000
|
1381
|
2
|
25000
|
1292
|
3
|
50000
|
1551
|
4
|
50000
|
1604
|
07版本
测试No |
数据量
|
用时
|
1
|
25000
|
6276
|
2
|
25000
|
6342
|
3
|
50000
|
10014
|
4
|
50000
|
9897
|
07版本,修改了写入类,改成了SXSSFWorkbook
测试No |
数据量
|
用时
|
1
|
25000
|
3224
|
2
|
25000
|
3457
|
3
|
50000
|
4044
|
4
|
50000
|
3924
|
说明对大数据量的导出,03版本的Excel基本模板基本上没有在时间上面对性能做出影响
但是07版本的导出,在时间上有较大的差异,在修改成
SXSSFWorkbook导出时间比之前有了较大的提示,
但是比03版本仍有不少差异
但是两个导出文件有3-4倍的差距,如果流量比较重要,或者网速比较重要可以用03,如果网速快,想提高服务器用03的导出
源码地址:
点击打开链接