1、jar准备:jodconverter-3.0-beta-2.jar 、juh-3.0.1.jar、jurt-3.0.1.jar、ridl-3.0.1.jar、unoil-3.0.1.jar、commons-io-1.4.jar。
2、新版的使用:
ManagedProcessOfficeManagerConfiguration configuration=
new ManagedProcessOfficeManagerConfiguration(OfficeConnectionMode.socket(8100));
File fileHome=new File("C:/Program Files (x86)/OpenOffice 4/");
configuration.setOfficeHome(fileHome);
OfficeManager officeManager = new ManagedProcessOfficeManager(configuration);
officeManager.start();
OfficeDocumentConverter converter = new OfficeDocumentConverter(officeManager);
File sourceFile= new File(inputFilePath);
File targetFile= new File(outputFilePath);
converter.convert(sourceFile,targetFile);
officeManager.stop();
业务逻辑自己编写,核心转换部分请大家参考。
3、测试:
FileOpenOfficePdf office2pdf = new FileOpenOfficePdf();
office2pdf.openOffice2Pdf("F:/sys.xls",
"F:/xls_" + new Date().getTime() + "." + PDF_POSTFIX);
测试结果:
XLS的线条没有了。
txt 文件的转换,出现如下结果:
4、解决txt 乱码的问题:
重新编辑打包:jodconverter-3.0-beta-2.jar ,修改该jar中的 net.sf.jodconverter.DefaultDocumentFormatRegistry 类文件,如下图所示:

5、OK!先到这。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/95917.html