上代码更为直接,望有助于您。
StringBuilder strPos = parseExcelChargePos(new File("D:\\code_project\\Advertisement_Income\\file_book\\trace_pd_java_2003.xls"));
private static StringBuilder parseExcelChargePos(File file) throws Exception{
StringBuilder Strposition = new StringBuilder();
Workbook wb = Workbook.getWorkbook(file);
Sheet sheet = wb.getSheets()[0];
for (int i = 0; i < sheet.getRows(); i++) {
Cell cell = sheet.getCell(3, i);
String content = cell.getContents();
if(content.equals(String.valueOf(100))){
Strposition.append(i);
Strposition.append(",");
}
}
return Strposition;
}
使用java的excel时,需要导入相关jar包为作为库的lib。
jar包名:jxl-2.6.jar
jar 包下载地址:http://files.cnblogs.com/files/liaolongjun/excel-jar.zip
网友评论