How does Java read xls files? This article mainly shares with you how to read xls files in java. I hope it can help you.
try { InputStream is = new FileInputStream(Thread.currentThread() .getContextClassLoader().getResource("123.xls").getPath()); Workbook rwb = Workbook.getWorkbook(is); Sheet rs = rwb.getSheet(0);// 参数设置读文件的第几页 int rsRows = rs.getRows(); // 获取Sheet表中所包含的总行数 TOTALROWS=rsRows; for (int i = 0; i < rsRows; i++) { Cell[] row = rs.getRow(i); String bid=row[0].getContents().trim(); BIDS.add(bid); PHONES.put(bid, row[1].getContents().trim()); } } catch (Exception e) { e.printStackTrace(); }
Related recommendations:
How to open an xls file in php Implementation code for using the DOM class to read XML files
Small example of php generating xls file
The above is the detailed content of How to read xls file in java. For more information, please follow other related articles on the PHP Chinese website!