[java]代码库
public static void operateAATP(String aatpPath) throws FileNotFoundException, IOException
{
XSSFWorkbook aatpExcel = new XSSFWorkbook(new FileInputStream(aatpPath));
XSSFSheet sheet = aatpExcel.getSheetAt(0);
XSSFRow row = sheet.getRow(1); //读取第二行的列数
//总行数
int trLength = sheet.getLastRowNum();
//总列数
int tdLength = row.getLastCellNum();
//循环读取
for(int i=0;i<tdLength;i++)
{
XSSFCell cell = row.getCell(i);
if (null != cell) {
switch (cell.getCellType()) {
case XSSFCell.CELL_TYPE_NUMERIC: // 数字
System.out.print(cell.getNumericCellValue()
+ " ");
break;
case XSSFCell.CELL_TYPE_STRING: // 字符串
System.out.print(cell.getStringCellValue()
+ " ");
break;
case XSSFCell.CELL_TYPE_BOOLEAN: // Boolean
System.out.println(cell.getBooleanCellValue()
+ " ");
break;
case XSSFCell.CELL_TYPE_FORMULA: // 公式
System.out.print(cell.getCellFormula() + " ");
break;
case XSSFCell.CELL_TYPE_BLANK: // 空值
System.out.println(" ");
break;
case XSSFCell.CELL_TYPE_ERROR: // 故障
System.out.println(" ");
break;
default:
System.out.print("未知类型 ");
break;
}
}
}
}
}
初级程序员
by: 微微 发表于:2016-08-22 18:02:19 顶(0) | 踩(0) 回复
回复评论