Hello Friend..........
              
               Am trying to read an excell sheet using apache poi and i got
all the values from excell sheet when i added an  extra row  between the
content  [          IN Brief:-   I have 19 row in ma excell sheet and all of
them contains at least 1 data when i added an empty row  in 13 th position
(Manually)      ]    IT creates null pointer exception and i cannot read the
rest of rows i tried to delete the empty row from excell sheet by using the
following code


FileInputStream fs =new FileInputStream(filename);
                                                        //sstrec = SSTRecord;
                                                        HSSFWorkbook wb = new 
HSSFWorkbook(fs);
                                                        int j=i+1;
                                                        HSSFSheet sheet = 
wb.getSheetAt(0);
                                                    //rows  = 
sheet.getPhysicalNumberOfRows();
                                                    int 
firstRow=sheet.getFirstRowNum();
                                                    rows=sheet.getLastRowNum();
                                                    System.out.println(rows);
                                                    
                                                    
                                                    boolean stop = false;
                                            boolean nonBlankRowFound;
                                            short c;
                                            HSSFRow lastRow = null;
                                            HSSFCell cell = null;

                                            while (stop == false) 
                                            {
                                                
                                                nonBlankRowFound = false;
                                                lastRow = sheet.getRow(12);
                                                for (c = 
lastRow.getFirstCellNum(); c <=
lastRow.getLastCellNum(); c++) {
                                                     cell = lastRow.getCell(c);
                                                    if (cell != null && 
lastRow.getCell(c).getCellType()
!= HSSFCell.CELL_TYPE_BLANK) {
                                                        nonBlankRowFound = true;
                                                    }
                                                }
                                                if (nonBlankRowFound == true) {
                                                    stop = true;
                                                } else {
                                                    sheet.removeRow(lastRow);
                                                }
                                            }


but results the same nullpointer exception 


      please.............. help me to sort out this issuee thnk
you..........

--
View this message in context: 
http://apache-poi.1045710.n5.nabble.com/Null-pointer-Exception-while-reading-xls-empty-row-tp4829181p4829181.html
Sent from the POI - Dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to