Hi all,

Thanks for the reply

Adrian Lynch

I will send my code tomorrow as I don't have access to the code right now

 Tohnmeister

I have a for loop to remove the sheets which loops from 0 to number of sheets 
to be removed.
If I have to remove sheet 0 , it fails at the 1st attempt itself. I believe 
this might be related to indexes but I couldn't figure it out

Please note that the same code works for .xlsx

Thanks

On Sep 1, 2014, at 10:50 AM, "Tohnmeister [via Apache POI]" 
<[email protected]<mailto:[email protected]>>
 wrote:

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 <[hidden 
email]</user/SendEmail.jtp?type=node&node=5716517&i=0>>:

> 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 <[hidden 
> email]</user/SendEmail.jtp?type=node&node=5716517&i=1>> 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<http://Nabble.com>.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden 
> > email]</user/SendEmail.jtp?type=node&node=5716517&i=2>
> > For additional commands, e-mail: [hidden 
> > email]</user/SendEmail.jtp?type=node&node=5716517&i=3>
> >
> >
>


________________________________
If you reply to this email, your message will be added to the discussion below:
http://apache-poi.1045710.n5.nabble.com/POI-3-11-NullPointerException-when-doing-removeSheetAT-for-xls-file-tp5716487p5716517.html
To unsubscribe from POI 3.11 NullPointerException when doing removeSheetAT() 
for .xls file, click 
here<http://apache-poi.1045710.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5716487&code=a2dhcm5lbmlAYWNtb29yZS5jb218NTcxNjQ4N3wtMjA5NjY0Mzcy>.
NAML<http://apache-poi.1045710.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>

________________________________
Notice: This message and any attachments may contain confidential or 
proprietary information and are only for the use of the intended recipient of 
this message. If you are not the intended recipient, please notify the sender 
by return email, and delete or destroy this and all copies of this message and 
all attachments. Any unauthorized disclosure, use, distribution or reproduction 
of this message or any attachments is prohibited and may be unlawful.




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

Reply via email to