Excel read

The following is a simple Excel read method

Basic steps to read Excel

Definition File Create Workbook Read Workbook Read Total Rows Get First Row Get Total Columns Read First Cell

 File file = new File("D:/xx.xls");

//return to workbook 

Workbook wk = Workbook.getWorkbook(file); 

//Returns the worksheet (Sheet) object array in the workbook (Workbook)

Sheet[] sheet = wk.getSheets();

for(Sheet shet:sheet){
  //Get the total number of rows contained in the Sheet. Generally, the title of the first row does not need to be read
  for(int i = 0; i < shet.getRows(); i++){
  //Get The total number of columns contained in the Sheet table
  for (int j = 0; j < shet.getColumns(); j++) {

    //Read content
    String cellinfo = shet.getCell(j, i).getContents();
    System.out.println(cellinfo);
    }
  }
}

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325305224&siteId=291194637