POI simple version EasyPoi Performance Test Series 1, poieasypoi
1. Basic functions: Export test cases, export 5 rows of data, an association class, 25000 or rows of data test demo main objectpublic
class
MsgClient
implements
java.io.Serializable {
/** id */
private
java.lang.String id;
// Phone number (primary key)
@Excel
(name =
"Phone Number"
, width =
20
, orderNum =
"2"
)
private
String clientPhone =
null
;
// CUSTOMER NAME
@Excel
(name =
"Name"
, orderNum =
"1"
)
private
String clientName =
null
;
// Group
@ExcelEntity
private
MsgClientGroup group =
null
;
// Remarks
@Excel
(name =
"Remarks"
)
private
String remark =
null
;
// Birthday
@Excel
(name =
"Date of Birth"
, format =
"yyyy-MM-dd"
, width =
20
)
private
Date birthday =
null
;
// Creator
private
String createBy =
null
;
Associated objectpublic
class
MsgClientGroup
implements
Serializable {
/**
*
*/
private
static
final
long
serialVersionUID = 6946265640897464878L;
// Group name
@Excel
(name =
"Group"
)
private
String groupName =
null
;
/**
* Creator
*/
private
String createBy;
Test code
@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(
"James"
+ i);
client.setClientPhone(
"18797"
+ i);
client.setCreateBy(
"jueyue"
);
client.setId(
"1"
+ i);
client.setRemark(
"Test"
+ i);
MsgClientGroup group =
new
MsgClientGroup();
group.setGroupName(
"Test"
+ i);
client.setGroup(group);
list.add(client);
}
Date start =
new
Date();
Workbook workbook = ExcelExportUtil.exportExcel(
new
ExportParams(
"2412312"
,
"Test"
),
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();
}
Version 03 is used to export test results
Test No |
Data Volume |
Time spent |
1 |
25000 |
1381 |
2 |
25000 |
1292 |
3 |
50000 |
1551 |
4 |
50000 |
1604 |
Version 07
Test No |
Data Volume |
Time spent |
1 |
25000 |
6276 |
2 |
25000 |
6342 |
3 |
50000 |
10014 |
4 |
50000 |
9897
|
Version 07: changed the write class to SXSSFWorkbook.
Test No |
Data Volume |
Time spent |
1 |
25000 |
3224 |
2 |
25000 |
3457 |
3 |
50000 |
4044 |
4 |
50000 |
3924 |
This section describes how to export a large amount of data. The basic Excel template of version 03 does not affect performance in terms of time, but the export of Version 07 has a big difference in time, the export time after modification to SXSSFWorkbook is a little longer than before, but there are still many differences than the 03 version, but there are 3-4 differences between the two exported files. if the traffic is more important, or the network speed is more important, you can use 03. If the network speed is fast, you want to increase the server's export speed by using 03.
Source Code address: Click to open the link