Java 将 excel 转换为 pdf 或创建新的 pdf 文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18131849/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Convert excel to pdf or create new pdf file?
提问by ia.solano
I am developing a web app using java. I can create reports in excel files for the user to download. Now I am told to give the option of downloading it in a pdf file. Should I use a library to create pdf and write the content or look up a way to convert the excel file into pdf? I think the second option would be easier to develop, but are there any disadvantages on doing this? And if this is the best option, what would be a good library to convert xls to pdf?
我正在使用 java 开发一个网络应用程序。我可以在 excel 文件中创建报告供用户下载。现在我被告知可以选择将其下载为 pdf 文件。我应该使用库来创建 pdf 并编写内容还是查找将 excel 文件转换为 pdf 的方法?我认为第二种选择会更容易开发,但是这样做有什么缺点吗?如果这是最好的选择,那么将 xls 转换为 pdf 的好库是什么?
采纳答案by Daniel Kaplan
Looks like this question will help you: How to convert ms-Excel file to pdf in java
看起来这个问题会帮助你:How to convert ms-Excel file to pdf in java
They recommend iText there but you should be aware that Flying Saucerexists. This will let you render html/css as a PDF. It may be a better level of abstraction to work at.
他们在那里推荐 iText,但您应该知道Flying Saucer存在。这将让您将 html/css 呈现为 PDF。它可能是一个更好的抽象级别。
回答by StormeHawke
You might check out Apache FOP for PDF creation, and POI for reading the excel. I used both pretty extensively in my previous job.
您可以查看用于创建 PDF 的 Apache FOP,以及用于阅读 excel 的 POI。我在之前的工作中广泛使用了这两种方法。