public static void load(String excelPath,String sheetname) {
Class clazz=Case.class;
try {
Workbook workbook=WorkbookFactory.create(new File(excelPath));
Sheet sheet=workbook.getSheet(sheetname);
//获取第一行
Row titlerow=sheet.getRow(0);
//有多少列
int cellNum=titlerow.getLastCellNum();
for (int i = 0; i < cellNum; i++) {
//根据索引获取对应的列
Cell cell=titlerow.getCell(i, MissingCellPolicy.CREATE_NULL_AS_BLANK);
//设置列的类型是字符串
cell.setCellType(CellType.STRING);
String titleValue=cell.getStringCellValue();
String actuallValue=titleValue.substring(0, titleValue.indexOf("("));
System.out.println(actuallValue);
}
} catch (EncryptedDocumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}