Home  >  Article  >  Java  >  How to read xls file in java

How to read xls file in java

小云云
小云云Original
2018-03-07 09:13:382729browse

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:

xls file processing

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn