Note that indexes are updated when you delete a sheet. E.g. at first you have three sheets, namely 0, 1 and 2. After removing 0, you have two sheets, namely 0 (was 1) and 1 (was 2). If your code looks like this:
workbook.removeSheetAt(0); workbook.removeSheetAt(2); Then that will fail indeed, because index 2 is not valid anymore after removing sheet 0. 2014-08-30 0:20 GMT+02:00 Adrian Lynch <[email protected]>: > Show us your code. It's hard to even suggest what might be the issue > without some code to look over. > > A > > > On 29 August 2014 22:09, kgtokm <[email protected]> wrote: > > > Hi, > > > > My .xls workbook contains several sheets and when removing sheet using > > removeSheetAt(index) method it throws NullPointerException. > > > > For eg if I have have 3 sheets in my workboox and if I remove 3nd and > then > > 2nd sheet it works fine but if I remove 1st sheet or 2nd sheet by keeping > > 3rd sheet then it throws NullPointerException > > > > Iam using poi 3.11 version > > > > Any help would be appreciated. > > > > Thanks in advance > > > > > > > > -- > > View this message in context: > > > http://apache-poi.1045710.n5.nabble.com/POI-3-11-NullPointerException-when-doing-removeSheetAT-for-xls-file-tp5716487.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] > > > > >
