Bug 48495 - Exception received after using shiftRows and cloneSheet
Summary: Exception received after using shiftRows and cloneSheet
Status: RESOLVED WORKSFORME
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.6-FINAL
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-06 11:23 UTC by bob Stox
Modified: 2015-08-06 21:06 UTC (History)
1 user (show)



Attachments
Test spreadsheet (8.66 KB, application/octet-stream)
2010-01-06 11:23 UTC, bob Stox
Details

Note You need to log in before you can comment on or make changes to this bug.
Description bob Stox 2010-01-06 11:23:25 UTC
Created attachment 24805 [details]
Test spreadsheet

I have an excel spreadsheet with one worksheet which I use as a template for multiple worksheets.  Prior to cloning the worksheet sometimes I need to insert a row into the worksheet.  When the program is trying to save the spreadsheet I receive the following exception:

org.apache.xmlbeans.impl.values.XmlValueDisconnectedException
	at org.apache.xmlbeans.impl.values.XmlObjectBase.check_orphaned(XmlObjectBase.java:1213)
	at org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTRowImpl.setCArray(Unknown Source)
	at org.apache.poi.xssf.usermodel.XSSFRow.onDocumentWrite(XSSFRow.java:392)
	at org.apache.poi.xssf.usermodel.XSSFSheet.write(XSSFSheet.java:2362)
	at org.apache.poi.xssf.usermodel.XSSFSheet.commit(XSSFSheet.java:2328)
	at org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:177)
	at org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:181)
	at org.apache.poi.POIXMLDocument.write(POIXMLDocument.java:214)
	at test.AATest.main(AATest.java:21)

I found this bug when converting from HSSF.

This is the test program that shows the error:
package test;
import java.io.*;

import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.*;
public class AATest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			Workbook wb = new XSSFWorkbook("AATest.xlsx");
			Sheet sheet = wb.getSheetAt(0);
			sheet.shiftRows(2, sheet.getLastRowNum(), 1, true, false);
			Row newRow = sheet.getRow(2);
			if (newRow == null) newRow = sheet.createRow(2);
			newRow.createCell(0).setCellValue(" Another Header");
			wb.cloneSheet(0);
		    FileOutputStream fileOut = new FileOutputStream("newWorkbook.xlsx");
		    wb.write(fileOut);
		    fileOut.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println("Done");
	}
}

It only happens when the worksheet is cloned.


I'll attach the spreadsheet.
Comment 1 Dominik Stadler 2013-08-23 18:27:19 UTC
I could not reproduce this any more with the latest version of POI, please try with that version and reopen the bug with an updated testcase which reproduces the problem.