poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Markus Christian <markusc...@gmail.com>
Subject ArrayIndexOutOfBoundsException while UpdatingFile
Date Sun, 11 Feb 2018 19:32:56 GMT
Hi,

I'm getting the following exception when updating/writing in a xlsx-file
with apache POI3.17:

  java.lang.ArrayIndexOutOfBoundsException: 1
    at
org.apache.poi.xssf.usermodel.XSSFTable.setCellReferences(XSSFTable.java:303)

atorg.apache.poi.xssf.usermodel.XSSFTable.getStartCellReference(XSSFTable.java:275)
    at
org.apache.poi.xssf.usermodel.XSSFTable.updateHeaders(XSSFTable.java:356)
    at org.apache.poi.xssf.usermodel.XSSFTable.writeTo(XSSFTable.java:102)
    at org.apache.poi.xssf.usermodel.XSSFTable.commit(XSSFTable.java:113)
    at org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:486)
    at org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:491)
    at org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:491)
    at org.apache.poi.POIXMLDocument.write(POIXMLDocument.java:242)
    at gui.Reiter.dateiSpeichern(Reiter.java:660)
    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)

it will be cause in the red line of the following code:

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


            fileAccess();
            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{

    }
thanks for some help to find the trigger,

Best regards Markus

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message