Bug 46662 - Writing a workbook twice throws XmlValueDisconnectedException
Summary: Writing a workbook twice throws XmlValueDisconnectedException
Status: RESOLVED DUPLICATE of bug 49940
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.7-FINAL
Hardware: PC Windows XP
: P2 normal with 9 votes (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2009-02-04 02:24 UTC by Vinu Kumar
Modified: 2014-07-16 21:09 UTC (History)
3 users (show)

Repro file for the issue (1.18 KB, application/octet-stream)
2009-02-04 02:24 UTC, Vinu Kumar
xlsx file used for testing (9.43 KB, application/octet-stream)
2009-02-04 02:25 UTC, Vinu Kumar

Note You need to log in before you can comment on or make changes to this bug.
Description Vinu Kumar 2009-02-04 02:24:04 UTC
Created attachment 23224 [details]
Repro file for the issue

Read a xlsx file. Write the same workbook to two different file. Closing FileOutputStream after second write throws 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(XmlComplexConten
        at org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTFontsImpl.setFontArray(Unknow
n Source)
        at org.apache.poi.xssf.model.StylesTable.writeTo(StylesTable.java:323)
        at org.apache.poi.xssf.model.StylesTable.commit(StylesTable.java:381)
        at org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:171)
        at org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:173)
        at org.apache.poi.POIXMLDocument.write(POIXMLDocument.java:199)
        at com.mytest.xssftest.crxlsfile(xssftest.java:39)
        at com.mytest.xssftest.main(xssftest.java:24)

Tested from latest svn trunk.
Comment 1 Vinu Kumar 2009-02-04 02:25:29 UTC
Created attachment 23225 [details]
xlsx file used for testing
Comment 2 GeraldoLuiz 2011-04-10 08:40:10 UTC
Same for me here. I need to mark some cells in a sheet already open and save it to a new file to download it so the user can see the modifications she's doing on the seet. 

If it's a xls workbook, all goes well but when I have a xlsx workbook, this exception is thrown. So, as a workarround, I have to read the workbook all over again everytime I need to mark and save it (and keep track of all the modifications to apply them in each iteration). 

It adds an unnecessary overhead to the process, so I'd like to see it solved asap.
Comment 3 Nick Burch 2011-04-10 14:55:41 UTC
I think this might be an xmlbeans bug - it doesn't look to me like we're doing anything wrong

Can you try a newer version of xmlbeans and see if it fixes it?
Comment 4 pbtura 2011-07-13 18:29:23 UTC
I was seeing this same issue in one of my projects. I tried replacing the xmlbeans jar with the latest version (2.5.0) and it had no effect.
Comment 5 Rohan 2012-03-31 07:12:22 UTC
Even i am facing the similar problem.
My project was working with xls (Excel 2003) but now we had to do changes to make it work with xlsx(Excel 2007).

I added the required jars xmlbeans-2.3.0.jar, ooxml-schemas-1.1.jar, poi-3.7.jar, poi-ooxml-3.7-20101029.jar, dom4j-1.6.1.jar 

Can anybody please help with this issue???????
Comment 6 Dhanashree 2012-04-02 06:31:01 UTC
I am also facing the above problem; first time when i write in the workbook, it works fine but when second time i try writing in the workbook i get the XMLValueDisconnectedException!!!
I have the required jars of poi,xmlbeans and dom4j jars

Can anybody please suggest a solution for this problem?????????
Comment 7 Dixon Jose 2012-04-02 06:53:20 UTC
Similar problem as above; I am trying to create a new project working with xlsx. Also i have imported the required jars.
But still getting the XMLValueDisconnectedException.
Does anyone have a solution to this????
Please help!!!
Comment 8 Snehal 2012-04-02 08:10:34 UTC
I am trying to use Excel 2007 (xlsx files), in my project, but i get the XMLValueDisconnectedException.
I have imported the jars
poi-ooxml-schemas-3.7, poi-3.7, poi-ooxml-3.7, xmlbeans-2.3  and dom4j jars

Still i get that exception.
Can anyone please look into this????

Comment 9 Pravin 2012-04-04 06:07:24 UTC

My Project is Excel based application where loads of excel file data gets processed. Currently we are using Office 2003 version (.xls format), we now want to switch to Office 2007 (.xlsx format). But when we try to overwrite the .xls file to .xlsx file it gives 'XMLValueDisconnectedException' Error.

We have tried numerous possibilities but nothing worked. It seems that it is related to POI JARs that we are using (POI 3.7).

Could you please help us out in the solution for the above problem? as we need to migrate the project ASAP.

Thanks in advance.

Pravin A. Khavnekar
Comment 10 Ajay Nair 2012-04-04 07:26:16 UTC

There is a need for our applications to be comaptible with Excel 2007 along with 2003. 

We have a multiple write functionality and with the POI 3.7 using Workbook and WorkbookFactory class works fine for 2003 version but fails for 2007 version. We get an XMLValueDisconnectedException when we try to write the same workbook twice.

Any help in this view is appreciated.

Revert in case you need any further info.

Comment 11 Nick Burch 2012-04-04 11:33:07 UTC
For those people who this bug affects, please remember that POI is a volunteer project. The quickest way to get a bug fixed is often to work on it yourself!

There may be a xmlbeans bug here, or there may be a mistake in how POI is calling xmlbeans. Likely avenues for investigation are trying to come up with a much smaller set of code calling xmlbeans that triggers the problem (so a bug report can be raised with the xmlbeans project), and reviewing (likely with a debugger) the POI calls to xmlbeans to identify what is triggering the disconnection
Comment 12 Divya Gambhir 2012-04-04 13:12:45 UTC
My Project is planning to use xlsx (Excel 2007) file ( previously used was xls (Excel 2003) ) so when we try to overwrite on the Xcel (xlsx file) for second time it gives XMLValueDisconnectedException


Does any one have the solution for the above problem????”
Comment 13 Manoj R 2012-04-05 11:10:19 UTC
       My Project is planning to use .xlsx file, previously used was .xls.
so when i try to overwrite on the .xlsx file for the second time i am getting XMLValueDisconnectedException

Thanks in advance, 
Revert in case you need any further info...

Manoj R
Comment 14 Stefan 2012-09-04 10:21:40 UTC
I have the same problem,
it seems it hasnt been solved since i just downloaded the latest poi version 3.8
Comment 15 Dominik Stadler 2013-08-05 20:18:57 UTC
There are a number of bug reports for the same issue, duplicating this one to another one with more discussion.

*** This bug has been marked as a duplicate of bug 49940 ***