public static List<String[]> getData(Workbook wb, String sheetName) {
List<String[]> list = new ArrayList<String[]>();
Sheet st = sheetName == null ? wb.getSheetAt(0) : wb.getSheet(sheetName);
for (int i = 0; i <= st.getLastRowNum(); i++) {
Row row = st.getRow(i);
if (row != null) {
String[] rowData = new String[row.getLastCellNum()];
for (int j = 0; j < row.getLastCellNum(); j++) {
Cell cell = row.getCell(j);
rowData[j] = cell.toString();
}
list.add(rowData);
}
}
return list;
}
一般都是按行读的,列的话取数据是用 list.get(i)[0],list.get(i)[1]......