L
L
Lord Drous2017-02-01 12:24:41
Java
Lord Drous, 2017-02-01 12:24:41

How to display the names of those who have more than 4 years of experience?

Hello, I have a .xls file, 187504ec40614161abc2f41891756d50.png
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();
        }
    }
}

0c878728739a4cf8b181fa12f73927b4.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
marrs, 2017-02-01
@marrs

and if before switch
if( cellType == Cell.CELL_TYPE_NUMERIC & cell.getNumericCellValue() >= 4 )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question