How to read Excel cell having null values too in Java…?

前端 未结 5 1455
梦谈多话
梦谈多话 2021-02-09 13:17

I\'m using Apache POI 3.6. I\'ve a column which is blank. I would like to be able to read it and then move to the next column. Even if I could resolve the

5条回答
  •  名媛妹妹
    2021-02-09 13:47

    Try this

    List cellDataList = new ArrayList();
    XSSFWorkbook workbook = new XSSFWorkbook(fileInputStream);
    
                            XSSFSheet sheet = workbook.getSheetAt(0);
    
                            Iterator rows = sheet.rowIterator();
    
                            int number=sheet.getLastRowNum();
    
    
                            int lineNumber = 0;
    
                            while (rows.hasNext())
    
                            {
                                XSSFRow row = ((XSSFRow) rows.next());
                                lineNumber++;
                                if(lineNumber==1){continue;}
    
    
    
    
                                Iterator cells = row.cellIterator();
                                List cellTempList = new ArrayList();    
                                int current = 0, next =1;
                                while(cells.hasNext())
    
                                {
    
                                    XSSFCell cell = (XSSFCell) cells.next();
    
    
                                    current = cell.getColumnIndex();
    
    
                                    if(current

提交回复
热议问题