[SoapUI] 在SoapUI里获取Excel中多行数据并存入List

ArrayList<ArrayList<String>> getCellValuesH( String filePath, String sheetName,int tr1,int tr2,int td1,int td2){
ArrayList<ArrayList<String>> cellValues = new ArrayList<ArrayList<String>>();
try{
File file = new File(filePath);
XSSFWorkbook wb = new XSSFWorkbook(new FileInputStream(filePath));
XSSFSheet sheet = wb.getSheet(sheetName);
int trLength = sheet.getLastRowNum();
Row row = sheet.getRow(0);
int tdLength = row.getLastCellNum();
String cellValue;
if(sheet != null){
for(int i=tr1; i<=tr2; i++){
ArrayList<String> rowCellValue = new ArrayList<String>();
Row row1 = sheet.getRow(i);
for(int j=td1; j<=td2; j++){
cellValue = row1.getCell(j);
rowCellValue.add(cellValue.trim());
}
cellValues.add(rowCellValue);
}
}
return cellValues;
}
catch (Exception e){
e.printStackTrace();
return null;
}
}
上一篇:Life Forms


下一篇:Java获取某年第一天和最后一天