简体   繁体   中英

How to convert the excel file format xls and xlsx vice versa in java

I try to change the excel file format xls and xlsx vice versa in java by using jobconveter jar in Windows OS https://code.google.com/archive/p/jodconverter/

 File xlsFile = new File("input/test.xls");
 File xlsxFile = new File("input/FileConverted.xlsx");
 OfficeManager officeManager = new efaultOfficeManagerConfiguration().buildOfficeManager();
 officeManager.start();
 OfficeDocumentConverter converter = new OfficeDocumentConverter(officeManager);
 converter.convert(xlsFile, xlsxFile);
 officeManager.stop();

but when I try and running the code, following error was occurred

Exception in thread "main" java.lang.IllegalStateException: officeHome not set and could not be auto-detected at org.artofsolving.jodconverter.office.DefaultOfficeManagerConfiguration.buildOfficeManager(DefaultOfficeManagerConfiguration.java:163)

Please give me the suggestion/solution to solve this error

OR another better way to convert the excel file type in java

jodconverter works with Openoffice service. so you should have installed Openoffice on your machine. jodconverter automatically discover the office service and convert document via the service. if you have installed Openoffice be sure the office service up and running.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM