Welcome to 16892 Developer Community-Open, Learning,Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I need to check and validate the cells types from a single line in my XLS file. I like to read only one line, to avoid problems. Here's my code to read all the lines:

while (rowIterator.hasNext()) {
    Row row = (Row) rowIterator.next();

    // Descantando a primeira linha com o header
    if (row.getRowNum() == 0) {
        continue;
    }

    Iterator cellIterator = row.cellIterator();
    ItemExcel item = new ItemExcel();
    itens.add(item);

    while (cellIterator.hasNext()) {
        Cell cell = (Cell) cellIterator.next();

        switch (cell.getColumnIndex()) {
        case 0:
            item.setDado0((int) cell.getNumericCellValue());
            break;
        case 1:
            item.setDado1(formatter.formatCellValue(cell));
            break;
        case 2:
            item.setDado2(formatter.formatCellValue(cell));
            break;
        case 3:
            item.setDado3(formatter.formatCellValue(cell));
            break;
        case 4:
            item.setDado4(formatter.formatCellValue(cell));
            break;
        case 5:
            item.setDado5(cell.getNumericCellValue());
            break;
        }
    }
}

But I need to only check a single line, how can I do this?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
3.9k views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to 16892 Developer Community-Open, Learning and Share
...