Read complex xlsx using Apache poi

Viewed 1520

Hi i want to read the below complex xlsx file using apache poi.

InputStream inputStream = content.getInputStream();
        XSSFWorkbook wb = new XSSFWorkbook(inputStream);
        XSSFSheet sheet = wb.getSheetAt(0);
        XSSFRow row;
        XSSFCell cell;

        Iterator rows = sheet.rowIterator();

        while (rows.hasNext())
        {
            row=(XSSFRow) rows.next();
            Iterator cells = row.cellIterator();
            while (cells.hasNext())
            {
                cell=(XSSFCell) cells.next();
                if (cell.getCellType() == XSSFCell.CELL_TYPE_STRING)
                {
                    System.out.print(cell.getStringCellValue()+" ");
                }
                else if(cell.getCellType() == XSSFCell.CELL_TYPE_NUMERIC)
                {
                    System.out.print(cell.getNumericCellValue()+" ");
                }
            }
        }

The above code is used to read the files.

How can i read the xlsx file and prepare object like

Guest Name = abc
Email = abc@mail.com

enter image description here

XLSX file

1 Answers
Related