读取EXCEL

public int biubiu() throws Exception {
String fileToBeRead = "D:\xinkai\demo.xls";//要打開的Excel的位置
HSSFWorkbook excel = new HSSFWorkbook(new FileInputStream(fileToBeRead));

    HSSFSheet sheet = excel.getSheetAt(0);

    if (sheet != null) {
        for (int i = 0; i < sheet.getLastRowNum(); i++) {
            HSSFRow rows = sheet.getRow(i);
            if (rows != null) {
                HSSFCell cell_0 = rows.getCell(0);
                HSSFCell cell_1 = rows.getCell(1);
            }
        }
    }
    return 1;
}

你可能感兴趣的:(读取EXCEL)