I would like to gather the relevant Excel cells into a list for a sequence comparison. However, I failed to get those cell values with conditions into the list by using below codes (nothing is printed in console as expected).
I tried using startsWith
and other condition syntax but I am not sure if this is the issue or I did sth wrong in prior.
HSSFSheet dispcolsheet = workbook2.getSheet(0);
Iterator<Row> colRowItr = dispcolsheet.rowIterator();
List<String> colstatuslist = new ArrayList<String>();
while (colRowItr.hasNext()){
Row row = colRowItr.next();
Cell colname = row.getCell(0);
if ("ABC_".contains(colname.getStringCellValue())) {
colstatuslist.add(row.getCell(1).getStringCellValue());
System.out.println(colstatuslist);
}
}
My xls file looks like:
name |status
ABC_1 | TRUE
ABC_2 | FALSE
ABC_3 | TRUE
.
.
.
I expect to store the TRUE FALSE TRUE
from column B
in sequence so that I could get()
them to use for comparison, like get(0)
would be the status of ABC_1
as TRUE
, get(1)
would be the status of ABC_2
as FALSE
and so on.
Thank you.