/**
*基本的读取excel获取每行每列数据
* @throws InvalidFormatException
*/
public static void poiReadExcel(File file) throws IOException, InvalidFormatException{
//创建文件输入流对象
InputStream is = new FileInputStream(file);
//创建 POI文件系统对象
Workbook wb = WorkbookFactory.create(is);
//获取工作薄
Sheet sheet = wb.getSheetAt(0);
//声明行对象
Row row = null;
//通过循环获取每一行
for (int i = 0; sheet.getRow(i)!=null; i++) {
row = sheet.getRow(i);
//循环获取一行的中列
String str="";
for (int j = 0; row.getCell(j)!=null; j++) {
str+=row.getCell(j).toString()+",";
}
System.out.println(str);
}
}
依赖的jar包如下