forked from fanruan/easyexcel
Jiaju Zhuang
5 years ago
7 changed files with 136 additions and 7 deletions
@ -0,0 +1,60 @@
|
||||
package com.alibaba.easyexcel.test.temp.large; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author Jiaju Zhuang |
||||
*/ |
||||
@Data |
||||
public class LargeData { |
||||
|
||||
private String str1; |
||||
|
||||
private String str2; |
||||
|
||||
private String str3; |
||||
|
||||
private String str4; |
||||
|
||||
private String str5; |
||||
|
||||
private String str6; |
||||
|
||||
private String str7; |
||||
|
||||
private String str8; |
||||
|
||||
private String str9; |
||||
|
||||
private String str10; |
||||
|
||||
private String str11; |
||||
|
||||
private String str12; |
||||
|
||||
private String str13; |
||||
|
||||
private String str14; |
||||
|
||||
private String str15; |
||||
|
||||
private String str16; |
||||
|
||||
private String str17; |
||||
|
||||
private String str18; |
||||
|
||||
private String str19; |
||||
|
||||
private String str20; |
||||
|
||||
private String str21; |
||||
|
||||
private String str22; |
||||
|
||||
private String str23; |
||||
|
||||
private String str24; |
||||
|
||||
private String str25; |
||||
} |
@ -0,0 +1,33 @@
|
||||
package com.alibaba.easyexcel.test.temp.large; |
||||
|
||||
import org.junit.Assert; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
import com.alibaba.excel.context.AnalysisContext; |
||||
import com.alibaba.excel.event.AnalysisEventListener; |
||||
import com.alibaba.fastjson.JSON; |
||||
|
||||
/** |
||||
* @author Jiaju Zhuang |
||||
*/ |
||||
public class LargeDataListener extends AnalysisEventListener<LargeData> { |
||||
private static final Logger LOGGER = LoggerFactory.getLogger(LargeDataListener.class); |
||||
private int count = 0; |
||||
|
||||
@Override |
||||
public void invoke(LargeData data, AnalysisContext context) { |
||||
if (count == 0) { |
||||
LOGGER.info("First row:{}", JSON.toJSONString(data)); |
||||
} |
||||
count++; |
||||
if (count % 100000 == 0) { |
||||
LOGGER.info("Already read:{}", count); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void doAfterAllAnalysed(AnalysisContext context) { |
||||
LOGGER.info("Large row count:{}", count); |
||||
} |
||||
} |
@ -0,0 +1,26 @@
|
||||
package com.alibaba.easyexcel.test.temp.large; |
||||
|
||||
import java.io.FileInputStream; |
||||
|
||||
import org.junit.Test; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
import com.alibaba.excel.EasyExcel; |
||||
import com.alibaba.excel.cache.MapCache; |
||||
|
||||
/** |
||||
* |
||||
* @author Jiaju Zhuang |
||||
*/ |
||||
public class LargeDataTest { |
||||
private static final Logger LOGGER = LoggerFactory.getLogger(LargeDataTest.class); |
||||
|
||||
@Test |
||||
public void read() throws Exception { |
||||
long start = System.currentTimeMillis(); |
||||
EasyExcel.read(new FileInputStream("D:\\test\\MRP生产视图(1).xlsx"), LargeData.class, new LargeDataListener()).readCache(new eh) |
||||
.headRowNumber(2).sheet().doRead(); |
||||
LOGGER.info("Large data total time spent:{}", System.currentTimeMillis() - start); |
||||
} |
||||
} |
Loading…
Reference in new issue