Невозможно вставить данные, используя POI для нулевых значений в таблице Excel

Я пытаюсь найти пустое значение в листе excel (xlsx) и заменить его строкой, подобной & quot; ENTER VALUE & quot; используя мою программу с библиотекой Apache POI, как показано ниже

Я могу читать и идентифицировать пустые / нулевые значения в таблице Excel, но не могу вставить любое значение в эти ячейки

public static void main(String args[]) throws IOException, InvalidFormatException
    {



                FileInputStream inputFile = new FileInputStream("//Users//suk//Documents/tes//testexcel.xlsx");

        //now initializing the Workbook with this inputFie


        // Create workbook using WorkbookFactory util method

         Workbook wb = WorkbookFactory.create(inputFile);

         // creating helper for writing cells

         CreationHelper createHelper = wb.getCreationHelper();

        // setting the workbook to handle null

         wb.setMissingCellPolicy(Row.CREATE_NULL_AS_BLANK);


        Sheet sheet = wb.getSheetAt(0);


        for (Row row : sheet) {
            int lastCellNo =row.getLastCellNum();
            int firstCellNo=row.getFirstCellNum();

            int rowNo =row.getRowNum();
            System.out.println(" row number = "+rowNo);
            System.out.println(" last cell no = "+lastCellNo);


            for(int i=firstCellNo;i<lastCellNo;i++){
                System.out.println("************");

                Cell cell = row.getCell(i);
                int colIndex =cell.getColumnIndex();
                if(cell==null)
                {
                    System.out.println(" The Cell:"+colIndex+" for row "+row.getRowNum()+" is NULL");
                }




              System.out.println(" column  index  = "+colIndex);


             int cellType = cell.getCellType();
             System.out.println(" cell type ="+cellType);

             // writing a switch case statement

             switch(cellType)
             {

             case 0:
             {
                double numValue = cell.getNumericCellValue();
                //System.out.println(numValue);
                 break;
             }
             case 1:
             {
                 String cellString = cell.getStringCellValue();
                 System.out.println("----String value = "+cellString+"---String length ="+cellString.length());

                 // here checking null consition

            /*   if(cellString == null || cellString.equalsIgnoreCase("") || cellString.length()<=0 || cellString.equalsIgnoreCase(" "))
                 {
                     // here creating the cell value after last cell


                 } */
                 break;
             }
             case 4:
             {
                  boolean bolValue =cell.getBooleanCellValue();
                  //System.out.println(bolValue);
                  break;
             }

             // for case of blank cell

             case 3:
             {

                 //int lastCellPlus =lastCellNo+1;
                 //System.out.println("last+1 column ="+lastCellPlus);
                 //row.createCell(lastCellPlus).setCellValue(" NULL VALUE..PLEASE ENTER VALUE ");

                 System.out.println(" cell details = "+cell.getColumnIndex()+" row details ="+row.getRowNum());
                 cell.setCellValue(createHelper.createRichTextString("ENTER VALUE"));
                 System.out.println(" Sucessfully written error");

                  break;
             }


             default: 
                 System.out.println(" unknown format");
                 break;

             }// switch

          } // row and cell iterator


          }
        }

}

Ниже приведен фрагмент кода, с помощью которого я определяю его значение Blank / Null и пытаюсь вставить строку, но не записываю в эту ячейку.

case 3:
             {

                 //int lastCellPlus =lastCellNo+1;
                 //System.out.println("last+1 column ="+lastCellPlus);
                 //row.createCell(lastCellPlus).setCellValue(" NULL VALUE..PLEASE ENTER VALUE ");

                 System.out.println(" cell details = "+cell.getColumnIndex()+" row details ="+row.getRowNum());
                 cell.setCellValue(createHelper.createRichTextString("ENTER VALUE"));
                 System.out.println(" Sucessfully written error");

                  break;
             }

Ответы на вопрос(2)

Ваш ответ на вопрос