如何读取xlsx表格内容

需要jar包:

dom4j-2.1.1jar

commons-io-2.6.jar

poi-4.0.0.jar

poi-ooxml-4.0.0.jar

poi-ooxml-schemas-4.0.0.jar

poi-scratchpad-3.9.jar

xmlbeans-3.0.1.jar

 

 CeshiService ceshiservice=new CeshiService();

File fi=new File(路径);

FileInputStream in=null;

try{

  in =new FileInputStream(fi);

}catch(FileNotFoundException e1){

  e1.printStackTrace();

}

XSSFWorkbook wb=null;

try{

  wb=new XSSFWorkbook(in);

}catch(IOException e){

  e.prinStackTrace();

}

 

Sheet sheet=wb.getSheetAt(0);

int fristRowNum=sheet.gerFirstRowNum();

int lastRowNum=sheet.getLastRowNum();

 

Row row=null;

for(int i=FirstRowNum+1;i<lastRowNum;i++){

  row=sheet.getRow(i);//获取第一行数据

  Cell cell=row.getCell(0);//获取i行第一列数据

 

}

posted @ 2019-06-27 21:25  fdbnf  阅读(446)  评论(0编辑  收藏  举报