Home > Java > javaTutorial > body text

How to read xls file in java

小云云
Release: 2018-03-07 09:13:38
Original
2751 people have browsed it

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();
		}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template