`
yuhai.china
  • 浏览: 154945 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

java读excel文件

阅读更多
public static void test() {
		int count = 16;
		File tmp = new File("F:\\听辩第一次\\铃音" + String.valueOf(count)
				+ "midi-1.xls");
		try {
			Workbook workbook = Workbook.getWorkbook(tmp);
			for (String sheetname : new String[] { "Sheet2" }) {
				Sheet sheet = workbook.getSheet(sheetname);
				int rows = sheet.getRows();
				for (int i = 1; i < rows; i++) {
					StringBuilder sb = new StringBuilder();
					if (sheet.getRow(i).length < 5) {
						System.out.println(sheet.getRow(i)[0].getContents());
						continue;
					}
					if (!(sheet.getRow(i)[2].getContents().equals("OK"))) {
						System.out.println(sheet.getRow(i)[0].getContents());
					}

				}
				
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics