poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 59158] New: Error when trying to read/write the same excel multiple times (no parallel reads or writes )
Date Thu, 10 Mar 2016 00:57:35 GMT
https://bz.apache.org/bugzilla/show_bug.cgi?id=59158

            Bug ID: 59158
           Summary: Error when trying to read/write the same excel
                    multiple times (no parallel reads or writes )
           Product: POI
           Version: 3.13-FINAL
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
          Assignee: dev@poi.apache.org
          Reporter: limesdevelopment@gmail.com

I got the message : Exception in thread "main"
org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException: Rule M2.4
exception : this error should NEVER happen! Please raise a bug at
https://bz.apache.org/bugzilla/enter_bug.cgi?product=POI and attach a file that
triggers it, thanks!
    at
org.apache.poi.openxml4j.opc.internal.ContentTypeManager.getContentType(ContentTypeManager.java:343)
    at
org.apache.poi.openxml4j.opc.internal.ContentTypeManager.removeContentType(ContentTypeManager.java:256)
    at org.apache.poi.openxml4j.opc.OPCPackage.removePart(OPCPackage.java:943)
    at
org.apache.poi.openxml4j.opc.PackagePart.getOutputStream(PackagePart.java:522)
    at
org.apache.poi.xssf.usermodel.XSSFWorkbook.commit(XSSFWorkbook.java:1678)
    at org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:341)
    at org.apache.poi.POIXMLDocument.write(POIXMLDocument.java:206)

Since the file that triggers it is fairly big I'm attaching the code that
triggers it.
This code is the very beginning, the only lines before it are declarations and
initializations. Written in Java 8 u 74. Good luck ! :)

for(String folder : godine){
            XSSFWorkbook wbTemp = new XSSFWorkbook();
            wbTemp.createSheet();
            FileOutputStream fo = new
FileOutputStream(lokacijaResursa+"\\statistika-"+folder+".xlsx");
            HashMap<String,Integer> pozicija = new HashMap<>();
            napraviCelije(wbTemp,100,200);
            for(int i=1;i<=12;i++) {
                try {
                    XSSFWorkbook mjesec = new XSSFWorkbook(new
FileInputStream(new File(lokacijaResursa + "\\" + folder + "\\" + i +
".xlsx")));
                    XSSFSheet sheetMjesec = mjesec.getSheetAt(0);
                    popuni(wbTemp, mjesec, pozicija, i);
                }
                catch (Exception ex){}
            }
            wbTemp.write(fo);
            fo.close();
            XSSFWorkbook wb = new XSSFWorkbook(new
FileInputStream(lokacijaResursa+"\\statistika-"+folder+".xlsx"));
            int numOfCells = 0;
            try{
                for(int i=3;;i++){
                    Row r = wb.getSheetAt(0).getRow(1);
                    Cell c = r.getCell(i,Row.CREATE_NULL_AS_BLANK);
                    if(c.getCellType() == Cell.CELL_TYPE_BLANK)
                        break;
                    numOfCells++;
                }
                for(int i=2;;i++){
                    Row r = wb.getSheetAt(0).getRow(i);
                    if(r.getCell(0,Row.CREATE_NULL_AS_BLANK).getCellType() ==
Cell.CELL_TYPE_BLANK)
                        break;
                    for(int j=3;j<numOfCells;j++){
                        Cell c = r.getCell(j,Row.CREATE_NULL_AS_BLANK);
                        if(c.getCellType() == Cell.CELL_TYPE_BLANK)
                            break;
                        else c.setCellValue(0);
                    }
                }
            }
            catch (NullPointerException ex){
                System.out.println("Nema fajlova");
                System.exit(0);
            }
            wb.close();
            fo = new FileOutputStream(new
File(lokacijaResursa+"\\statistika-"+folder+".xlsx"));
            wb.write(fo);
            fo.close();
        }

-- 
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


Mime
View raw message