Workbook book = Workbook.getWorkbook(excel);
Sheet sheet = book.getSheet(0);
int clos = sheet.getColumns();//得到所有的列
int rows = sheet.getRows();//得到所有的行
for (int i = 1; i < rows; i++) {
for (int j = 0; j < clos; j++) {
//sheet.getCell(j, i).getContents();//第一個是列數,第二個是行數
String columnValue = "";
if ("DATE".equals(dataTypeMap.get(titles[j]))) {
DateCell dc = (DateCell) sheet.getCell(j, i);
Date data = dc.getDate();
SimpleDateFormat dataFormat = new SimpleDateFormat("yyyy-MM-dd");
String columnValue = dataFormat.format(data);
} else {
columnValue = sheet.getCell(j, i).getContents();
}
}
}
轉載于:https://www.cnblogs.com/BobXie85/p/9857377.html