Hi Adrian Lynch 

Below is my code for fetching and deleting all the tabs that are not
required. 

Workbook wb=null;
Sheet sheet=null;
for (int a = 0; a < sheetCount; a++) {
                inStream = new FileInputStream(txtFile.getText().trim());
               
if(txtFile.getText().trim().substring(txtFile.getText().trim().indexOf(".")
+ 1).equalsIgnoreCase("xls"))
                        wb = new HSSFWorkbook(inStream);
                else
                        wb = new XSSFWorkbook(inStream);
                workingSheetName = wb.getSheetName(a);
                
                //get all other tabs to delete
                for (int b = 0; b < wb.getNumberOfSheets(); b++) {
                   if
(!wb.getSheetName(b).trim().equalsIgnoreCase(workingSheetName.trim()))
                        tabsToDelete.add(wb.getSheetName(b));
                }

                //now delete those tabs
                for (int c = 0; c < tabsToDelete.size(); c++) {
                    if (tabsToDelete.get(c) != null)
                        wb.removeSheetAt(wb.getSheetIndex((String)
tabsToDelete.get(c))); //This is where my application fails 
                }
}





--
View this message in context: 
http://apache-poi.1045710.n5.nabble.com/POI-3-11-NullPointerException-when-doing-removeSheetAT-for-xls-file-tp5716487p5716521.html
Sent from the POI - User mailing list archive at Nabble.com.

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

Reply via email to