null excetion when using workbook write function

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

null excetion when using workbook write function

Kevin Yao
hi,
I get a null exception when I use workbook write function with Apache POI.
My java code is

try (OutputStream out = new FileOutputStream(saveUrl)) {
    workbook.write(out);
} catch (IOException e) {
    System.err.println(e.getMessage());
}


The exception log is shown below.

java.lang.NullPointerException
at
org.apache.poi.poifs.filesystem.FilteringDirectoryNode$FilteringIterator.<init>(FilteringDirectoryNode.java:193)
at
org.apache.poi.poifs.filesystem.FilteringDirectoryNode$FilteringIterator.<init>(FilteringDirectoryNode.java:188)
at
org.apache.poi.poifs.filesystem.FilteringDirectoryNode.getEntries(FilteringDirectoryNode.java:101)
at
org.apache.poi.poifs.filesystem.FilteringDirectoryNode.iterator(FilteringDirectoryNode.java:105)
at org.apache.poi.poifs.filesystem.EntryUtils.copyNodes(EntryUtils.java:71)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.write(HSSFWorkbook.java:1407)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.write(HSSFWorkbook.java:1375)
at QuestionnaireExcel.writeExcelToLocal(QuestionnaireExcel.java:42)
at Main.main(Main.java:18)

The exception is the same as the url
*https://stackoverflow.com/questions/35654570/nullpointerexception-on-writing-excel-file-with-apache-poi
<https://stackoverflow.com/questions/35654570/nullpointerexception-on-writing-excel-file-with-apache-poi>.*

I searched a lot on Google but didn't find a useful solution. Could you
give me some advice to solve it ?

Thanks,
Kevin
Reply | Threaded
Open this post in threaded view
|

Re: null excetion when using workbook write function

pj.fanning
The directoryEntry that is causing in the NullPointerException is set in the
HSSFWorkbook constructor.

Could you be passing a null into this constructor?



--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-Dev-f2312866.html

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

Reply | Threaded
Open this post in threaded view
|

Re: null excetion when using workbook write function

Kevin Yao
In reply to this post by Kevin Yao
Can  andbody help me ? I will be very grateful.

Thanks,
Kevin

On Fri, Jan 4, 2019 at 8:12 PM Kevin Yao <[hidden email]> wrote:

> hi,
> I get a null exception when I use workbook write function with Apache POI.
> My java code is
>
> try (OutputStream out = new FileOutputStream(saveUrl)) {
>     workbook.write(out);
> } catch (IOException e) {
>     System.err.println(e.getMessage());
> }
>
>
> The exception log is shown below.
>
> java.lang.NullPointerException
> at
> org.apache.poi.poifs.filesystem.FilteringDirectoryNode$FilteringIterator.<init>(FilteringDirectoryNode.java:193)
> at
> org.apache.poi.poifs.filesystem.FilteringDirectoryNode$FilteringIterator.<init>(FilteringDirectoryNode.java:188)
> at
> org.apache.poi.poifs.filesystem.FilteringDirectoryNode.getEntries(FilteringDirectoryNode.java:101)
> at
> org.apache.poi.poifs.filesystem.FilteringDirectoryNode.iterator(FilteringDirectoryNode.java:105)
> at org.apache.poi.poifs.filesystem.EntryUtils.copyNodes(EntryUtils.java:71)
> at org.apache.poi.hssf.usermodel.HSSFWorkbook.write(HSSFWorkbook.java:1407)
> at org.apache.poi.hssf.usermodel.HSSFWorkbook.write(HSSFWorkbook.java:1375)
> at QuestionnaireExcel.writeExcelToLocal(QuestionnaireExcel.java:42)
> at Main.main(Main.java:18)
>
> The exception is the same as the url
> *https://stackoverflow.com/questions/35654570/nullpointerexception-on-writing-excel-file-with-apache-poi
> <https://stackoverflow.com/questions/35654570/nullpointerexception-on-writing-excel-file-with-apache-poi>.*
>
> I searched a lot on Google but didn't find a useful solution. Could you
> give me some advice to solve it ?
>
> Thanks,
> Kevin
>
Reply | Threaded
Open this post in threaded view
|

Re: null excetion when using workbook write function

Kevin Yao
I am very disappointed about that.

On Sat, Jan 5, 2019 at 10:20 AM Kevin Yao <[hidden email]> wrote:

> Can  andbody help me ? I will be very grateful.
>
> Thanks,
> Kevin
>
> On Fri, Jan 4, 2019 at 8:12 PM Kevin Yao <[hidden email]> wrote:
>
>> hi,
>> I get a null exception when I use workbook write function with Apache POI.
>> My java code is
>>
>> try (OutputStream out = new FileOutputStream(saveUrl)) {
>>     workbook.write(out);
>> } catch (IOException e) {
>>     System.err.println(e.getMessage());
>> }
>>
>>
>> The exception log is shown below.
>>
>> java.lang.NullPointerException
>> at
>> org.apache.poi.poifs.filesystem.FilteringDirectoryNode$FilteringIterator.<init>(FilteringDirectoryNode.java:193)
>> at
>> org.apache.poi.poifs.filesystem.FilteringDirectoryNode$FilteringIterator.<init>(FilteringDirectoryNode.java:188)
>> at
>> org.apache.poi.poifs.filesystem.FilteringDirectoryNode.getEntries(FilteringDirectoryNode.java:101)
>> at
>> org.apache.poi.poifs.filesystem.FilteringDirectoryNode.iterator(FilteringDirectoryNode.java:105)
>> at
>> org.apache.poi.poifs.filesystem.EntryUtils.copyNodes(EntryUtils.java:71)
>> at
>> org.apache.poi.hssf.usermodel.HSSFWorkbook.write(HSSFWorkbook.java:1407)
>> at
>> org.apache.poi.hssf.usermodel.HSSFWorkbook.write(HSSFWorkbook.java:1375)
>> at QuestionnaireExcel.writeExcelToLocal(QuestionnaireExcel.java:42)
>> at Main.main(Main.java:18)
>>
>> The exception is the same as the url
>> *https://stackoverflow.com/questions/35654570/nullpointerexception-on-writing-excel-file-with-apache-poi
>> <https://stackoverflow.com/questions/35654570/nullpointerexception-on-writing-excel-file-with-apache-poi>.*
>>
>> I searched a lot on Google but didn't find a useful solution. Could you
>> give me some advice to solve it ?
>>
>> Thanks,
>> Kevin
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: null excetion when using workbook write function

Dominik Stadler-2
Hi,

You received an answer at
https://lists.apache.org/thread.html/460102624d77cf10f0e6a259c2f84163f73f5772bfdc6bcf38377a43@%3Cdev.poi.apache.org%3E
but you did not react in any way to that, so what do you expect?

If you post to dev-list, you are expected to also look at the dev-list for
answers.

Dominik.

On Sun, Jan 13, 2019 at 5:43 AM Kevin Yao <[hidden email]> wrote:

> I am very disappointed about that.
>
> On Sat, Jan 5, 2019 at 10:20 AM Kevin Yao <[hidden email]> wrote:
>
> > Can  andbody help me ? I will be very grateful.
> >
> > Thanks,
> > Kevin
> >
> > On Fri, Jan 4, 2019 at 8:12 PM Kevin Yao <[hidden email]> wrote:
> >
> >> hi,
> >> I get a null exception when I use workbook write function with Apache
> POI.
> >> My java code is
> >>
> >> try (OutputStream out = new FileOutputStream(saveUrl)) {
> >>     workbook.write(out);
> >> } catch (IOException e) {
> >>     System.err.println(e.getMessage());
> >> }
> >>
> >>
> >> The exception log is shown below.
> >>
> >> java.lang.NullPointerException
> >> at
> >>
> org.apache.poi.poifs.filesystem.FilteringDirectoryNode$FilteringIterator.<init>(FilteringDirectoryNode.java:193)
> >> at
> >>
> org.apache.poi.poifs.filesystem.FilteringDirectoryNode$FilteringIterator.<init>(FilteringDirectoryNode.java:188)
> >> at
> >>
> org.apache.poi.poifs.filesystem.FilteringDirectoryNode.getEntries(FilteringDirectoryNode.java:101)
> >> at
> >>
> org.apache.poi.poifs.filesystem.FilteringDirectoryNode.iterator(FilteringDirectoryNode.java:105)
> >> at
> >> org.apache.poi.poifs.filesystem.EntryUtils.copyNodes(EntryUtils.java:71)
> >> at
> >> org.apache.poi.hssf.usermodel.HSSFWorkbook.write(HSSFWorkbook.java:1407)
> >> at
> >> org.apache.poi.hssf.usermodel.HSSFWorkbook.write(HSSFWorkbook.java:1375)
> >> at QuestionnaireExcel.writeExcelToLocal(QuestionnaireExcel.java:42)
> >> at Main.main(Main.java:18)
> >>
> >> The exception is the same as the url
> >> *
> https://stackoverflow.com/questions/35654570/nullpointerexception-on-writing-excel-file-with-apache-poi
> >> <
> https://stackoverflow.com/questions/35654570/nullpointerexception-on-writing-excel-file-with-apache-poi
> >.*
> >>
> >> I searched a lot on Google but didn't find a useful solution. Could you
> >> give me some advice to solve it ?
> >>
> >> Thanks,
> >> Kevin
> >>
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: null excetion when using workbook write function

Kevin Yao
Hi,
Sorry, I always use mail to communicate with apache community, so I didn't
check dev-list for reply answsers. In my expectation, I think it would
reply under my email like you. Now I got it.
Thank you,
Kevin

On Sun, Jan 13, 2019 at 4:43 PM Dominik Stadler <[hidden email]> wrote:

> Hi,
>
> You received an answer at
>
> https://lists.apache.org/thread.html/460102624d77cf10f0e6a259c2f84163f73f5772bfdc6bcf38377a43@%3Cdev.poi.apache.org%3E
> but you did not react in any way to that, so what do you expect?
>
> If you post to dev-list, you are expected to also look at the dev-list for
> answers.
>
> Dominik.
>
> On Sun, Jan 13, 2019 at 5:43 AM Kevin Yao <[hidden email]> wrote:
>
> > I am very disappointed about that.
> >
> > On Sat, Jan 5, 2019 at 10:20 AM Kevin Yao <[hidden email]>
> wrote:
> >
> > > Can  andbody help me ? I will be very grateful.
> > >
> > > Thanks,
> > > Kevin
> > >
> > > On Fri, Jan 4, 2019 at 8:12 PM Kevin Yao <[hidden email]>
> wrote:
> > >
> > >> hi,
> > >> I get a null exception when I use workbook write function with Apache
> > POI.
> > >> My java code is
> > >>
> > >> try (OutputStream out = new FileOutputStream(saveUrl)) {
> > >>     workbook.write(out);
> > >> } catch (IOException e) {
> > >>     System.err.println(e.getMessage());
> > >> }
> > >>
> > >>
> > >> The exception log is shown below.
> > >>
> > >> java.lang.NullPointerException
> > >> at
> > >>
> >
> org.apache.poi.poifs.filesystem.FilteringDirectoryNode$FilteringIterator.<init>(FilteringDirectoryNode.java:193)
> > >> at
> > >>
> >
> org.apache.poi.poifs.filesystem.FilteringDirectoryNode$FilteringIterator.<init>(FilteringDirectoryNode.java:188)
> > >> at
> > >>
> >
> org.apache.poi.poifs.filesystem.FilteringDirectoryNode.getEntries(FilteringDirectoryNode.java:101)
> > >> at
> > >>
> >
> org.apache.poi.poifs.filesystem.FilteringDirectoryNode.iterator(FilteringDirectoryNode.java:105)
> > >> at
> > >>
> org.apache.poi.poifs.filesystem.EntryUtils.copyNodes(EntryUtils.java:71)
> > >> at
> > >>
> org.apache.poi.hssf.usermodel.HSSFWorkbook.write(HSSFWorkbook.java:1407)
> > >> at
> > >>
> org.apache.poi.hssf.usermodel.HSSFWorkbook.write(HSSFWorkbook.java:1375)
> > >> at QuestionnaireExcel.writeExcelToLocal(QuestionnaireExcel.java:42)
> > >> at Main.main(Main.java:18)
> > >>
> > >> The exception is the same as the url
> > >> *
> >
> https://stackoverflow.com/questions/35654570/nullpointerexception-on-writing-excel-file-with-apache-poi
> > >> <
> >
> https://stackoverflow.com/questions/35654570/nullpointerexception-on-writing-excel-file-with-apache-poi
> > >.*
> > >>
> > >> I searched a lot on Google but didn't find a useful solution. Could
> you
> > >> give me some advice to solve it ?
> > >>
> > >> Thanks,
> > >> Kevin
> > >>
> > >
> >
>