https://issues.apache.org/bugzilla/show_bug.cgi?id=56468
--- Comment #8 from [email protected] --- My initial report indicated that bug 55033 may be related. Please ignore that remark. I cannot even replicate that bug while testing to see if Ralph's patch fixed it. The patch looks to me like it fixes the problems with the posted code. Thanks again! However, I did discover that adding a line to the test breaks another part. If you add something like ... cell.setCellValue("Hi"); sheet.setRepeatingRows(new CellRangeAddress(0, 0, 0, 0)); ... causes org.apache.xmlbeans.impl.values.XmlValueDisconnectedException at org.apache.xmlbeans.impl.values.XmlObjectBase.check_orphaned(XmlObjectBase.java:1213) at org.apache.xmlbeans.impl.values.XmlObjectBase.newCursor(XmlObjectBase.java:243) at org.apache.xmlbeans.impl.values.XmlComplexContentImpl.arraySetterHelper(XmlComplexContentImpl.java:1073) at org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTDefinedNamesImpl.setDefinedNameArray(Unknown Source) at org.apache.poi.xssf.usermodel.XSSFWorkbook.saveNamedRanges(XSSFWorkbook.java:1288) at org.apache.poi.xssf.usermodel.XSSFWorkbook.commit(XSSFWorkbook.java:1309) at org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:322) at org.apache.poi.POIXMLDocument.write(POIXMLDocument.java:173) at com.myprovident.excel.XLWorkbook.write(XLWorkbook.java:114) I believe saveNamedRanges recreates the CTDefinedName collection in the underlying CTWorkbook but does not recreate the enveloping XSSFName collection in the enveloping XSSFWorkbook. I found a fix by replacing the code names.setDefinedNameArray(nr); workbook.setDefinedNames(names); with the code (some of which is based on a snippet from function "onDocumentRead") names.setDefinedNameArray(nr); if(workbook.isSetDefinedNames()) { workbook.unsetDefinedNames(); } workbook.setDefinedNames(names); // Re-process the named ranges namedRanges = new ArrayList<XSSFName>(); if(workbook.isSetDefinedNames()) { for(CTDefinedName ctName : workbook.getDefinedNames().getDefinedNameArray()) { namedRanges.add(new XSSFName(ctName, this)); } } Does this look reasonable to you? My tests have the combination of your patch and this change working great. Do you think this should be part of the same patch or under a different bug report? -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
