mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
add test
This commit is contained in:
parent
a7ea726968
commit
16e903f795
@ -18,6 +18,7 @@ import org.junit.Test;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Excel sax方式读取
|
* Excel sax方式读取
|
||||||
@ -133,13 +134,12 @@ public class ExcelSaxReadTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void handle03CellTest() {
|
public void handle03CellTest() {
|
||||||
ExcelUtil.readBySax("d:/test/test.xls", -1, new RowHandler() {
|
ExcelUtil.readBySax("test.xls", -1, new RowHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCell(final int sheetIndex, final long rowIndex, final int cellIndex, final Object value, final CellStyle xssfCellStyle) {
|
public void handleCell(final int sheetIndex, final long rowIndex, final int cellIndex, final Object value, final CellStyle xssfCellStyle) {
|
||||||
Console.log("{} {} {}", rowIndex, cellIndex, value);
|
//Console.log("{} {} {}", rowIndex, cellIndex, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -224,4 +224,23 @@ public class ExcelSaxReadTest {
|
|||||||
ExcelUtil.readBySax("d:/test/WhiteListTemplate.xlsm", -1,
|
ExcelUtil.readBySax("d:/test/WhiteListTemplate.xlsm", -1,
|
||||||
(sheetIndex, rowIndex, rowlist) -> Console.log("[{}] [{}] {}", sheetIndex, rowIndex, rowlist));
|
(sheetIndex, rowIndex, rowlist) -> Console.log("[{}] [{}] {}", sheetIndex, rowIndex, rowlist));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void doAfterAllAnalysedTest() {
|
||||||
|
final String path = "readBySax.xls";
|
||||||
|
final AtomicInteger doAfterAllAnalysedTime = new AtomicInteger(0);
|
||||||
|
ExcelUtil.readBySax(path, -1, new RowHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(final int sheetIndex, final long rowIndex, final List<Object> rowCells) {
|
||||||
|
//Console.log("sheetIndex={};rowIndex={},rowCells={}",sheetIndex,rowIndex,rowCells);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doAfterAllAnalysed() {
|
||||||
|
doAfterAllAnalysedTime.addAndGet(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//总共2个sheet页,读取所有sheet时,一共执行doAfterAllAnalysed2次。
|
||||||
|
Assert.assertEquals(2, doAfterAllAnalysedTime.intValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
BIN
hutool-poi/src/test/resources/readBySax.xls
Executable file
BIN
hutool-poi/src/test/resources/readBySax.xls
Executable file
Binary file not shown.
BIN
hutool-poi/src/test/resources/test.xls
Executable file
BIN
hutool-poi/src/test/resources/test.xls
Executable file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user