Reputation: 1933
I have converted .xls file to .ods by using below command in terminal
COMMAND : soffice --headless --convert-to ods abcd.xls
After conversion I am not able to read fileName.ods using SpreadSheet API of jOpenDocument1.3.jar. When ever I try to read .ods file it will throw NullPointer Exception .
I am working in Ubuntu platform, if I convert .xls file to .ods using LibreOffice then it is working fine but if I convert it using soffice terminal then it is throwing exception!.
Is there any way to convert file(s) using command line, so that Java code able to read it properly.
I am using below code to read converted fileName.ods file .
File file = new File(path);
String sheetName = "SheetName"; // spread Sheet Name
Sheet sheet = SpreadSheet.createFromFile(file).getSheet(sheetName);
"createFromFile" is giving NullPointer Exception
ava.lang.NullPointerException
at org.jopendocument.dom.ODPackage.getODDocument(Unknown Source)
at org.jopendocument.dom.ODPackage.getSpreadSheet(Unknown Source)
at org.jopendocument.dom.spreadsheet.SpreadSheet.createFromFile(Unknown Source)
at com.thales.dbtool.controller.DBManageController.getUiParamsFromExcel(DBManageController.java:1316)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandl
Any help will be appreciated.
Upvotes: 0
Views: 35