You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by Kevin Yao <ah...@gmail.com> on 2019/01/04 12:12:27 UTC

null excetion when using workbook write function

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

Re: null excetion when using workbook write function

Posted by Kevin Yao <ah...@gmail.com>.
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 <ce...@apache.org> 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 <ah...@gmail.com> wrote:
>
> > I am very disappointed about that.
> >
> > On Sat, Jan 5, 2019 at 10:20 AM Kevin Yao <ah...@gmail.com>
> wrote:
> >
> > > Can  andbody help me ? I will be very grateful.
> > >
> > > Thanks,
> > > Kevin
> > >
> > > On Fri, Jan 4, 2019 at 8:12 PM Kevin Yao <ah...@gmail.com>
> 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
> > >>
> > >
> >
>

Re: null excetion when using workbook write function

Posted by Dominik Stadler <ce...@apache.org>.
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 <ah...@gmail.com> wrote:

> I am very disappointed about that.
>
> On Sat, Jan 5, 2019 at 10:20 AM Kevin Yao <ah...@gmail.com> wrote:
>
> > Can  andbody help me ? I will be very grateful.
> >
> > Thanks,
> > Kevin
> >
> > On Fri, Jan 4, 2019 at 8:12 PM Kevin Yao <ah...@gmail.com> 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
> >>
> >
>

Re: null excetion when using workbook write function

Posted by Kevin Yao <ah...@gmail.com>.
I am very disappointed about that.

On Sat, Jan 5, 2019 at 10:20 AM Kevin Yao <ah...@gmail.com> wrote:

> Can  andbody help me ? I will be very grateful.
>
> Thanks,
> Kevin
>
> On Fri, Jan 4, 2019 at 8:12 PM Kevin Yao <ah...@gmail.com> 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
>>
>

Re: null excetion when using workbook write function

Posted by Kevin Yao <ah...@gmail.com>.
Can  andbody help me ? I will be very grateful.

Thanks,
Kevin

On Fri, Jan 4, 2019 at 8:12 PM Kevin Yao <ah...@gmail.com> 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
>

Re: null excetion when using workbook write function

Posted by "pj.fanning" <fa...@yahoo.com>.
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org