add readExcel for "NO fields"
This commit is contained in:
47
test/com/lxyer/excel/ExcelKitTest.java
Normal file
47
test/com/lxyer/excel/ExcelKitTest.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package com.lxyer.excel;
|
||||
|
||||
import com.lxyer.excel.poi.ExcelKit;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author: liangxianyou at 2018/9/15 7:52.
|
||||
*/
|
||||
public class ExcelKitTest {
|
||||
|
||||
//read excel by fields
|
||||
@Test
|
||||
public void readTest() throws IOException {
|
||||
/*String sql1 = "select a, b, c from Sheet1";
|
||||
String sql2 = "select a, b, c from Sheet1 where a=1 order by b";
|
||||
String sql3 = "select a, b, c from Sheet1 s1, Sheet2 s2 order by";
|
||||
String sql4 = "select a, b, c from Sheet1 s1, Sheet2 s2 where order by";
|
||||
String select = sql1.substring(0,sql1.indexOf("from")).replace("select", "").replace(" ", "");
|
||||
|
||||
System.out.println(sql1.substring(0,sql1.indexOf("from")).replace("select", "").replace(" ", ""));
|
||||
*/
|
||||
|
||||
String[] fields ={"a", "b", "c"};
|
||||
File file = new File("res/test.xlsx");
|
||||
List<Map> list = ExcelKit.readExcel(file, fields);
|
||||
System.out.println(list.size());
|
||||
|
||||
}
|
||||
|
||||
//read excel no fields
|
||||
@Test
|
||||
public void readTest2() throws IOException {
|
||||
List<Map> list = ExcelKit.readExcel(new File("res/test.xlsx"));
|
||||
|
||||
list.forEach(x->{
|
||||
x.forEach((k,v)->{
|
||||
System.out.println(String.format("%s:%s", k, v));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user