Getting error while writting to xls file using POI API

251 views
Skip to first unread message

Arvind Bhakar

unread,
Dec 18, 2014, 8:09:01 AM12/18/14
to seleniu...@googlegroups.com
Hi,

Getting this error  while writing to xls file using POI API. It works fine if I write only once but throw error when try to write to 2 different files.

org.apache.xmlbeans.impl.values.XmlValueDisconnectedException
    at org.apache.xmlbeans.impl.values.XmlObjectBase.check_orphaned(XmlObjectBase.java:1258)
    at org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTXfImpl.getXfId(Unknown Source)
    at org.apache.poi.xssf.model.StylesTable.getStyleAt(StylesTable.java:183)
    at org.apache.poi.xssf.usermodel.XSSFCell.getCellStyle(XSSFCell.java:427)
    at org.apache.poi.xssf.usermodel.XSSFCell.getCellStyle(XSSFCell.java:63)
    at org.apache.poi.ss.usermodel.DateUtil.isCellDateFormatted(DateUtil.java:280)
    at com.bcatman.util.Xls_Reader.getCellData(Xls_Reader.java:149)
    at com.bcatman.base.TestBase.readExcelData(TestBase.java:159)
    at com.bcatman.suite.CatalogImportExport.ImportSimpleExcel.testcaseImportSimpleExcel(ImportSimpleExcel.java:89)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
    at org.testng.TestRunner.privateRun(TestRunner.java:767)
    at org.testng.TestRunner.run(TestRunner.java:617)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
    at org.testng.SuiteRunner.run(SuiteRunner.java:240)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
    at org.testng.TestNG.run(TestNG.java:1057)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
org.apache.xmlbeans.impl.values.XmlValueDisconnectedException
    at org.apache.xmlbeans.impl.values.XmlObjectBase.check_orphaned(XmlObjectBase.java:1258)
    at org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTXfImpl.getXfId(Unknown Source)
    at org.apache.poi.xssf.model.StylesTable.getStyleAt(StylesTable.java:183)
    at org.apache.poi.xssf.usermodel.XSSFCell.getCellStyle(XSSFCell.java:427)
    at org.apache.poi.xssf.usermodel.XSSFCell.getCellStyle(XSSFCell.java:63)
    at org.apache.poi.ss.usermodel.DateUtil.isCellDateFormatted(DateUtil.java:280)
    at com.bcatman.util.Xls_Reader.getCellData(Xls_Reader.java:149)
    at com.bcatman.base.TestBase.readExcelData(TestBase.java:159)
    at com.bcatman.suite.CatalogImportExport.ImportSimpleExcel.testcaseImportSimpleExcel(ImportSimpleExcel.java:89)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
    at org.testng.TestRunner.privateRun(TestRunner.java:767)
    at org.testng.TestRunner.run(TestRunner.java:617)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
    at org.testng.SuiteRunner.run(SuiteRunner.java:240)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)

Please provide the solution.


Krishnan Mahadevan

unread,
Dec 20, 2014, 12:12:20 AM12/20/14
to seleniu...@googlegroups.com
Please post your query on a apache poi forum. Your question doesnt have anything to do with selenium. 

Krishnan M
iSent.iPad.
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/b5575920-c603-4a3a-93ac-ba00a31017f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

pranab singh

unread,
Dec 20, 2014, 3:50:56 AM12/20/14
to seleniu...@googlegroups.com

Hi
You have to change the row,column n sheet no etc etc to write on,
Their is methods for this just check to write/read. Hope u made some mistake in ur code.

Abhi Ram

unread,
Jan 16, 2015, 3:04:47 AM1/16/15
to seleniu...@googlegroups.com
HI, Arvind Bhakar,

For all these excel reading and writing i created a one open source library called as POIRE. This library contains different methods for excel as of now. You can get this jar from the below URL.

POIRE

Its a Microsoft Ms-office(Excel,Ms Word,PowerPoint) files handling with Java with the help of the POI classes. This API was develop on the top of the POI library. Its has so many methods for working with the Ms-office files(Excel,Ms Word,PowerPoint). These methods will work on the both the binary(.xls, .doc, .ppt) and XML(.xlsx, .docx, .pptx). with the help of the NPOIFSFileSystem & OPCPackage classes in the POI. with these classes the reading and writing into file would be faster. In this i included so many user friendly methods with the help of POI Library.

GitHub

https://github.com/ssirekumar/POIRE
https://github.com/ssirekumar/POIRE/releases

Example method Usages From the POIRE.

//Example_1
/* The below line of the code to get the data from the sheet in ArrayList<ArrayList<String>>*/
File fileObject = new File("C:\\TestExcel\\WorkBook_2010_1.xlsx");
ArrayList<ArrayList<String>> countRwo23 = ExcelDataEngine.getExcelDataWithSheetNumber(fileObject.getAbsolutePath(), 1,0);

for(ArrayList<String> listValue : countRwo23){
System.out.println(listValue);
}

If you are getting any issues with the build of POIRE please let me know or else log a issues in GitHub.

Thanks

Reply all
Reply to author
Forward
0 new messages