下载 poi包(excel解析需要用到的jar包-4.0.1):
下载地址
提取码:1c9p
https://pan.baidu.com/s/1tr6XgUMgW-NO4cB-H55A_Q
Java源码:
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class ExcelTest {
public static void main(String[] args) throws IOException {
// TODO 自动生成的方法存根
File file = new File("F:/file/Xxx.xlsx");
FileInputStream fis = new FileInputStream(file);
XSSFWorkbook wb = new XSSFWorkbook(new BufferedInputStream(fis));
printDoubleArray(getSheetData(wb.getSheet("XXXXX")));
}
//读取excel指定sheet中的各行数据,存入二维数组,包括首行
public static String[][] getSheetData(XSSFSheet sheet) throws IOException {
String[][] testArray = new String[sheet.getPhysicalNumberOfRows()][];
for(int rowId =0;rowId testSetList = new ArrayList();
for(int column=0;column