I got a exception as follow when copying sheet: Caused by: java.util.ConcurrentModificationException java.util.AbstractList$Itr.checkForComodification(AbstractList.java:449) java.util.AbstractList$Itr.next(AbstractList.java:420) org.apache.poi.hssf.record.ObjRecord.clone(ObjRecord.java:182) org.apache.poi.hssf.model.Sheet.cloneSheet(Sheet.java:320) org.apache.poi.hssf.usermodel.HSSFSheet.cloneSheet(HSSFSheet.java:114) org.apache.poi.hssf.usermodel.HSSFWorkbook.cloneSheet(HSSFWorkbook.java:337) snip It is caused by a bug of "clone" method in the "ObjRecord" class. public Object clone() { ObjRecord rec = new ObjRecord(); rec.subrecords = new ArrayList(); for ( Iterator iterator = subrecords.iterator(); iterator.hasNext(); ) subrecords.add(( (Record) iterator.next() ).clone()); return rec; } "subrecords.add" must be "rec.subrecords.add" in the "for" block. I got correct result after modification.
I dont want to add this patch without a testcase... seems risky to me. Could you please supply a short testcase that triggers this bug? Thanks.
Almost identical fix to bug 31092 (svn r353603) *** This bug has been marked as a duplicate of bug 31092 ***