Answer the question
In order to leave comments, you need to log in
How to display the names of those who have more than 4 years of experience?
Hello, I have a .xls file,
how can I run element by element or according to words to find those who have more than 4 experience, I understand the algorithm itself, but I don’t know how to run through the elements and output, I didn’t work with excel + java
code and output in java:
public class Main {
public static void main(String[] args) throws Exception {
InputStream in = new FileInputStream("Book.xls");
HSSFWorkbook wb = new HSSFWorkbook(in);
Sheet sheet = wb.getSheetAt(0);
Iterator<Row> it = sheet.iterator();
while (it.hasNext()) {
Row row = it.next();
Iterator<Cell> cells = row.iterator();
while (cells.hasNext()) {
Cell cell = cells.next();
int cellType = cell.getCellType();
switch (cellType) {
case Cell.CELL_TYPE_STRING:
System.out.print("|" + cell.getStringCellValue() + "|");
break;
case Cell.CELL_TYPE_NUMERIC:
System.out.print("[" + cell.getNumericCellValue() + "]");
break;
case Cell.CELL_TYPE_FORMULA:
System.out.print("[" + cell.getNumericCellValue() + "]");
break;
default:
System.out.print("|");
break;
}
}
System.out.println();
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question