You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2018/02/12 18:31:25 UTC

[Bug 62098] New: exceptions while updating xlsx-file

https://bz.apache.org/bugzilla/show_bug.cgi?id=62098

            Bug ID: 62098
           Summary: exceptions while updating xlsx-file
           Product: POI
           Version: 3.17-FINAL
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
          Assignee: dev@poi.apache.org
          Reporter: markusch23@gmail.com
  Target Milestone: ---

Created attachment 35728
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=35728&action=edit
test-File like the original

code that causes the bug:

        public void dateiSpeichern(){




                try (FileOutputStream outPutStream = new
FileOutputStream(actualFile)){


                        System.out.println("File: "+actualFile);
                        System.out.println("Sheet:
"+actualSheet.getSheetName());

                        //Daten abspeichern
                        Header header=actualSheet.getHeader();
                        header.setLeft(jtaZeitraum.getText());
                        header.setCenter(jtaAnschrift.getText());;
                        header.setRight(jtaVonBis.getText());

                        for(int i=0; i<datensatzListe.size(); i++){

                                XSSFRow row=actualSheet.getRow(i+3);
                                System.out.println("Row: "+row.getRowNum());
                                XSSFCell cell0=row.getCell(0);
                                cell0.setCellValue("");
                                XSSFCell cell1=row.getCell(1);
                                cell1.setCellValue("");
                                XSSFCell cell2=row.getCell(2);
                                cell2.setCellValue("");
                                XSSFCell cell3=row.getCell(3);
                                cell3.setCellValue("");
                                XSSFCell cell4=row.getCell(4);
                                cell4.setCellValue("");
                                XSSFCell cell5=row.getCell(5);
                                cell5.setCellValue("");
                                XSSFCell cell6=row.getCell(6);
                                cell6.setCellValue("");
                                XSSFCell cell7=row.getCell(7);
                                cell7.setCellValue("");
                                XSSFCell cell8=row.getCell(8);
                                cell8.setCellValue("");
                                XSSFCell cell9=row.getCell(9);
                                cell9.setCellValue("");
                                XSSFCell cell10=row.getCell(10);
                                cell10.setCellValue("");
                        }
                        for(int i=0; i<datensatzListe.size(); i++){

                                XSSFRow row=actualSheet.getRow(i+3);
                                System.out.println("Row: "+row.getRowNum());
                                XSSFCell cell0=row.getCell(0);
                                System.out.println("Cell:
"+cell0.getColumnIndex());
                               
cell0.setCellValue(datensatzListe.get(i).getEinnahmen());
                                XSSFCell cell1=row.getCell(1);
                               
cell1.setCellValue(datensatzListe.get(i).getMwstEin());
                                XSSFCell cell2=row.getCell(2);
                               
cell2.setCellValue(datensatzListe.get(i).getAusgaben());
                                XSSFCell cell3=row.getCell(3);
                               
cell3.setCellValue(datensatzListe.get(i).getMwst19Aus());
                                XSSFCell cell4=row.getCell(4);
                               
cell4.setCellValue(datensatzListe.get(i).getMwst7Aus());
                                XSSFCell cell5=row.getCell(5);
                               
cell5.setCellValue(datensatzListe.get(i).getRechnr());
                                XSSFCell cell6=row.getCell(6);
                               
cell6.setCellValue(datensatzListe.get(i).getZaehler());
                                XSSFCell cell7=row.getCell(7);
                               
cell7.setCellValue(datensatzListe.get(i).getDate());
                                XSSFCell cell8=row.getCell(8);
                               
cell8.setCellValue(datensatzListe.get(i).getVonFuer());
                                XSSFCell cell9=row.getCell(9);
                               
cell9.setCellValue(datensatzListe.get(i).getRubrik());
                                XSSFCell cell10=row.getCell(10);
                               
cell10.setCellValue(datensatzListe.get(i).getKonto());

                        }

                        tabelleAktualisieren();






                        actualWB.write(outPutStream);
                        outPutStream.flush();
                        outPutStream.close();
                        writerEx.flushFileWriter();


        } catch (IOException e) {
                e.printStackTrace();
                writerEx.printIOException(e);

        } catch (NullPointerException e1) {
                e1.printStackTrace();
                writerEx.printNullPointerException(e1);

        } catch (Exception e2) {
                e2.printStackTrace();
                writerEx.printException(e2);

        }finally{

        }


        }

The exception: 

java.lang.NullPointerException
        at gui.Reiter.dateiSpeichern(Reiter.java:576)
        at gui.Hauptfenster$4.actionPerformed(Hauptfenster.java:405)
        at
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
        at
javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
        at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
        at
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
        at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
        at
javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:833)
        at
javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:877)
        at java.awt.Component.processMouseEvent(Component.java:6533)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
        at java.awt.Component.processEvent(Component.java:6298)
        at java.awt.Container.processEvent(Container.java:2236)
        at java.awt.Component.dispatchEventImpl(Component.java:4889)
        at java.awt.Container.dispatchEventImpl(Container.java:2294)
        at java.awt.Component.dispatchEvent(Component.java:4711)
        at
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
        at
java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
        at java.awt.Container.dispatchEventImpl(Container.java:2280)
        at java.awt.Window.dispatchEventImpl(Window.java:2746)
        at java.awt.Component.dispatchEvent(Component.java:4711)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
        at java.awt.EventQueue.access$500(EventQueue.java:97)
        at java.awt.EventQueue$3.run(EventQueue.java:709)
        at java.awt.EventQueue$3.run(EventQueue.java:703)
        at java.security.AccessController.doPrivileged(Native Method)
        at
java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
        at
java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
        at java.awt.EventQueue$4.run(EventQueue.java:731)
        at java.awt.EventQueue$4.run(EventQueue.java:729)
        at java.security.AccessController.doPrivileged(Native Method)
        at
java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
        at
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
        at
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
        at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
        at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)


Thanks for checking this problem!

Best Regards Markus

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 62098] exceptions while updating xlsx-file

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62098

Javen O'Neal <on...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |RESOLVED
         Resolution|---                         |INVALID

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 62098] exceptions while updating xlsx-file

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62098

Nick Burch <ap...@gagravarr.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All
             Status|NEW                         |NEEDINFO

--- Comment #1 from Nick Burch <ap...@gagravarr.org> ---
There doesn't seem to be any Apache POI code involved in your stacktrace.
Therefore, it rather seems to be a bug in your code...

Can you write a short junit unit test case (or similar standalone program)
which shows the issue to be in POI?

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 62098] exceptions while updating xlsx-file

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62098

--- Comment #2 from Markus <ma...@gmail.com> ---
Created attachment 35730
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=35730&action=edit
my short standalone program and my xlsxFile

Hi,

with this short JavaFile with the code I got the following exception:

java.lang.NullPointerException
        at gui.WriteWorkbook.write(WriteWorkbook.java:42)
        at gui.WriteWorkbook.<init>(WriteWorkbook.java:22)
        at gui.WriteWorkbook.main(WriteWorkbook.java:113)

Best regards

Markus

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 62098] exceptions while updating xlsx-file

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62098

--- Comment #3 from PJ Fanning <fa...@yahoo.com> ---
Markus - the NullPointerException is in your code, not in Apache POI.

Line 42 in your code is
cell0=row.getCell(0);

So most likely the row is null.

I opened the xlsx file in your zip and the sheet called `test` is empty - which
might explain why getRow for that sheet is returning null.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org