The error message says that the NPE is ocurring at line 70. Which line is that? The one that's marked as 70 in the code cannot cause an NPE, so your actual line numbers must be different.
Look at line 70 and figure out what's null there. If you can't figure it out, add println() statements right before it to print out everything that you're assuming is not null and that could be causing the problem. If you still can't figure it out, post again, indicating which line is causing the problem.
Of course. You should beware of nulls, which are nasty things which hide in the corner and then come back to bite you. If sheet is a field, where was it initialised? Why didn’t you initialise it in the constructor?
Why would you expect that to fix anything. You already know that the problem is that sheet is null. Now you're saying you changed it to explicitly set sheet to null. So sheet is just as null as it was before.
What shall i initialize it with
Null means that reference does not point ot an object. So you need an HSSFSheet object, created appropriately according to the documentation and your requirements and use case.
And why is sheet static?
It would probably be a good idea for you to take a step back and spend some time learning the fundamentals of the Java language before attempting to use a complex API like POI.
sai rama krishna
Joined: May 29, 2009
sheet = workbook.getSheetAt(0);
Fixed above problem and printing the xml on console successfully.
How do I save and see it under say 'C' drive with say sampleXml.xml filename. Please advise.
Joined: Oct 13, 2005
You can save files the same way you save anything. I would start here, and you can find out about files in general here.