Есть excel файл. Нужно сделать поиск по файлу, найти string и вивести целий ряд. На Java(POI)

введите сюда описание изображения try { File file = new File("example.xlsx"); //creating a new file instance FileInputStream fis = new FileInputStream(file); //obtaining bytes from the file //creating Workbook instance that refers to .xlsx file
XSSFWorkbook wb = new XSSFWorkbook(fis); XSSFSheet sheet = wb.getSheetAt(0); //creating a Sheet object to retrieve object //iterating over excel file for (Row row : sheet) { Iterator cellIterator = row.cellIterator(); //iterating over each column while (cellIterator.hasNext()) { Cell cell = cellIterator.next(); String cellValue = null; switch (cell.getCellType()) { case Cell.CELL_TYPE_STRING: cellValue = cell.getStringCellValue(); break; case Cell.CELL_TYPE_NUMERIC: if (DateUtil.isCellDateFormatted(cell)) { cellValue = cell.getDateCellValue().toString(); } else { cellValue = Double.toString(cell.getNumericCellValue()); } break; } System.out.println(cellValue);//output all result } System.out.println(); } } catch (Exception e) { e.printStackTrace(); }


Ответы (0 шт):