https://issues.apache.org/bugzilla/show_bug.cgi?id=48495
Summary: Exception received after using shiftRows and
cloneSheet
Product: POI
Version: 3.6
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: XSSF
AssignedTo: [email protected]
ReportedBy: [email protected]
Created an attachment (id=24805)
--> (https://issues.apache.org/bugzilla/attachment.cgi?id=24805)
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.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- 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]