Java将XLS文件另存为PDF [英] Java save xls file as PDF

查看:235
本文介绍了Java将XLS文件另存为PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的Java程序,它创建.xls文件(Open Office Excel文件),我想将其另存为pdf.我在这里看到了一些答案,但没有一个对我有用.有没有简单而免费的方法来做到这一点? 该文件仅包含1页的.xls

I have a simple java program that creates .xls file (open office excel file), and I want to save it as pdf. I saw some answers here but none of them worked for me. Is there a simple and free way to do so? The file contains only 1 page of .xls

谢谢

推荐答案

不确定,请提供更多详细信息,共享代码,以使答案更加精确,但是从代码角度来看,可以通过Apache POI实现.在下面....

Not sure, please provide more details , share code so that the answer can be more precise, but for code perspective it can be achieved via Apache POI.something like below ....

 //Instantiate a new workbook with excel file path
Workbook workbook = new Workbook("F:\\FileTemp\\Book1.xls");

//Save the document in Pdf format
workbook.save("F:\\FileTemp\\MyPdfFile.pdf", FileFormatType.PDF);

这篇关于Java将XLS文件另存为PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆