依赖包:poi3.8相关包
依赖包下载地址: http://download.csdn.net/detail/sxg0205/8959391
</pre><pre name="code" class="java">private void test() {
XSSFWorkbook xwb;
try {
xwb = new XSSFWorkbook("D:\\excel\\test.xlsx");
// 读取excel文档中第一章的表格内容
XSSFSheet sheet = xwb.getSheetAt(0);
// 定义 row、cell
XSSFRow row;
String cell;
// 循环输出表格中的内容
for (int i = sheet.getFirstRowNum() + 1; i < sheet.getPhysicalNumberOfRows(); i++) {
row = sheet.getRow(i);
RSDefinedCause rsCause = new RSDefinedCause();
for (int j = row.getFirstCellNum(); j < 30; j++) {
if (null == row.getCell(j)) {
continue;
}
// 通过 row.getCell(j).toString() 获取单元格内容,
cell = row.getCell(j).toString().trim();
if (j == 0) {
// 第一列的值
} else if (j == 1) {
// 第二列的值
// } else if (j == 2) {
// // 第三列的值
}
}
}
System.out.println("success");
} catch (Exception e) {
e.printStackTrace();
}
}