0

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)

Any help will be appreciated.

3
  • Generally I would consider this a bug or something in the XLS the conversion tool does not support. I would have asked this on their forum: ask.libreoffice.org/en/questions
    – Rinzwind
    Commented May 11, 2017 at 10:16
  • Do you have this also when you use the libreoffice --headless command?
    – Bruni
    Commented May 11, 2017 at 11:20
  • @Bruni : We are facing the same issue there is no difference between soffice and libreoffice . After conversion the file size is more then the actual file . Is there any other way to convert .xls to .ods . Commented May 11, 2017 at 12:36

0

You must log in to answer this question.

Browse other questions tagged .