将Excel (.xls)转换为pdfs

时间:2023-01-15 11:41:30

Is there any php/java/open source software converters or php libraries that will convert an xls file to a pdf document?

是否有php/java/开源软件转换器或php库将xls文件转换为pdf文档?

Rundown: Have pre-existing code generating xls spreadsheets (circa 2002-2006, pre open xml version I believe), need to turn them into pdfs for various reasons.

简化:有已存在的生成xls电子表格的代码(大约2002-2006年,我认为是预打开的xml版本),需要出于各种原因将它们转换为pdfs。

Been searching everywhere including here. I think I just need a bump in the right direction, I'm sure there is something out there already that does it.

到处都在搜索,包括这里。我想我只是需要一个方向正确的碰撞,我确信已经有东西可以做到这一点。

2 个解决方案

#1


1  

You can convert XLS files to PDF on Linux by installing OpenOffice with a PDF writer as the default printer driver.

您可以在Linux上通过安装OpenOffice将PDF写入器作为默认打印机驱动程序将XLS文件转换为PDF。

Then, you can call OpenOffice (from PHP) using the "-p" command-line parameter, which will cause it to load a designated file and print it.

然后,您可以使用“-p”命令行参数调用OpenOffice(来自PHP),这将导致它加载指定的文件并打印它。

For example, if your file was "accounts.xls" you would call the following command:

例如,如果你的文件是“帐户”。您可以调用以下命令:

soffice -p accounts.xls

soffice - p accounts.xls

OpenOffice would load the "accounts.xls" file and "print" it to the PDF writer, which would be configured to save the PDF document to the desired filename.

OpenOffice将加载“帐户”。xls“文件”和“打印”到PDF写入器,该写入器将被配置为将PDF文档保存到所需的文件名。

GhostScript is a suitable PDF writer.

GhostScript是一个适合的PDF格式的作者。

The OpenOffice setup guide describes how to install and configure printer drivers using the "spadmin" utility, and discusses the use of ghostscript as a PDF writer: "Open Office Setup Guide - Appendix" http://www.openoffice.org/docs/setup_guide/appendix.html

OpenOffice安装指南描述了如何使用“spadmin”工具安装和配置打印机驱动程序,并讨论了如何使用ghostscript作为PDF编写器:“OpenOffice安装指南-附录”http://www.openoffice.org/docs/setup_guide/阑尾

You can call OpenOffice from PHP by using the backtick execution operator, or the "exec" function. You may also need to use PHP to move and/or rename the resulting PDF files:

您可以使用backtick执行操作符或“exec”函数从PHP调用OpenOffice。您可能还需要使用PHP来移动和/或重命名生成的PDF文件:

PHP: Program Execution Functions http://www.php.net/manual/en/ref.exec.php

PHP:程序执行函数http://www.php.net/manual/en/ref.exec.php

PHP: Filesystem: Rename http://www.php.net/manual/en/function.rename.php

PHP:文件系统:重命名http://www.php.net/manual/en/function.rename.php

OpenOffice is pretty good at processing XLS files, but it may not perfectly render every such file - so if you need the ultimate in compatibility you will have to use Microsoft Excel on a Windows Platform or emulator. "IT AsiaOne" looked at several alternatives to Microsoft Office (including OpenOffice) and wrote that "while none of the alternative suites promise ... full compatibility with Microsoft Office-created documents, in general, they do a decent job of translating Microsoft ".doc", ".ppt" and ".xls" file formats":

OpenOffice非常擅长处理XLS文件,但它可能不能完美地呈现每一个这样的文件——因此,如果您需要最终的兼容性,您必须在Windows平台或模拟器上使用Microsoft Excel。“IT AsiaOne”研究了微软Office(包括OpenOffice在内)的几个备选方案,并写道:“虽然没有一个替代套件可以保证……”与Microsoft office创建的文档完全兼容,总的来说,它们在翻译Microsoft方面做得不错”。医生”、“。ppt”和“。xls文件格式:

IT AsiaOne - Specials - Yours For The Picking http://it.asia1.com.sg/specials/mmedia20020724_001.html

IT AsiaOne - Specials——你的选择是http://. asia1.com.sg/specials/mmedia20020724_001.html。

Additional links:

额外的链接:

OpenOffice.org Home Page http://www.openoffice.org/

OpenOffice.org主页http://www.openoffice.org/

Ghostscript Home Page http://www.cs.wisc.edu/~ghost/

内容的主页http://www.cs.wisc.edu/ ~鬼/

PHP Home Page http://www.php.net/

PHP主页:http://www.php.net/

Google search strategy:

谷歌搜索策略:

openoffice scripting pdf linux ://www.google.com/search?q=openoffice%20scripting%20pdf%20linux

openoffice脚本pdf://www.google.com/search?

openoffice print "command line" ://www.google.com/search?q=openoffice%20scripting%20pdf%20linux

openoffice打印“命令行”:// /www.google.com/search?

followed by a search for "command line parameters" from the openoffice.org home page.

然后从openoffice.org主页搜索“命令行参数”。

ref: http://answers.google.com/answers/threadview/id/177241.html

裁判:http://answers.google.com/answers/threadview/id/177241.html

#2


2  

Since PHP is able to execute commands via shell in linux, this could be a good start.

由于PHP能够在linux中通过shell执行命令,这可能是一个良好的开端。

#1


1  

You can convert XLS files to PDF on Linux by installing OpenOffice with a PDF writer as the default printer driver.

您可以在Linux上通过安装OpenOffice将PDF写入器作为默认打印机驱动程序将XLS文件转换为PDF。

Then, you can call OpenOffice (from PHP) using the "-p" command-line parameter, which will cause it to load a designated file and print it.

然后,您可以使用“-p”命令行参数调用OpenOffice(来自PHP),这将导致它加载指定的文件并打印它。

For example, if your file was "accounts.xls" you would call the following command:

例如,如果你的文件是“帐户”。您可以调用以下命令:

soffice -p accounts.xls

soffice - p accounts.xls

OpenOffice would load the "accounts.xls" file and "print" it to the PDF writer, which would be configured to save the PDF document to the desired filename.

OpenOffice将加载“帐户”。xls“文件”和“打印”到PDF写入器,该写入器将被配置为将PDF文档保存到所需的文件名。

GhostScript is a suitable PDF writer.

GhostScript是一个适合的PDF格式的作者。

The OpenOffice setup guide describes how to install and configure printer drivers using the "spadmin" utility, and discusses the use of ghostscript as a PDF writer: "Open Office Setup Guide - Appendix" http://www.openoffice.org/docs/setup_guide/appendix.html

OpenOffice安装指南描述了如何使用“spadmin”工具安装和配置打印机驱动程序,并讨论了如何使用ghostscript作为PDF编写器:“OpenOffice安装指南-附录”http://www.openoffice.org/docs/setup_guide/阑尾

You can call OpenOffice from PHP by using the backtick execution operator, or the "exec" function. You may also need to use PHP to move and/or rename the resulting PDF files:

您可以使用backtick执行操作符或“exec”函数从PHP调用OpenOffice。您可能还需要使用PHP来移动和/或重命名生成的PDF文件:

PHP: Program Execution Functions http://www.php.net/manual/en/ref.exec.php

PHP:程序执行函数http://www.php.net/manual/en/ref.exec.php

PHP: Filesystem: Rename http://www.php.net/manual/en/function.rename.php

PHP:文件系统:重命名http://www.php.net/manual/en/function.rename.php

OpenOffice is pretty good at processing XLS files, but it may not perfectly render every such file - so if you need the ultimate in compatibility you will have to use Microsoft Excel on a Windows Platform or emulator. "IT AsiaOne" looked at several alternatives to Microsoft Office (including OpenOffice) and wrote that "while none of the alternative suites promise ... full compatibility with Microsoft Office-created documents, in general, they do a decent job of translating Microsoft ".doc", ".ppt" and ".xls" file formats":

OpenOffice非常擅长处理XLS文件,但它可能不能完美地呈现每一个这样的文件——因此,如果您需要最终的兼容性,您必须在Windows平台或模拟器上使用Microsoft Excel。“IT AsiaOne”研究了微软Office(包括OpenOffice在内)的几个备选方案,并写道:“虽然没有一个替代套件可以保证……”与Microsoft office创建的文档完全兼容,总的来说,它们在翻译Microsoft方面做得不错”。医生”、“。ppt”和“。xls文件格式:

IT AsiaOne - Specials - Yours For The Picking http://it.asia1.com.sg/specials/mmedia20020724_001.html

IT AsiaOne - Specials——你的选择是http://. asia1.com.sg/specials/mmedia20020724_001.html。

Additional links:

额外的链接:

OpenOffice.org Home Page http://www.openoffice.org/

OpenOffice.org主页http://www.openoffice.org/

Ghostscript Home Page http://www.cs.wisc.edu/~ghost/

内容的主页http://www.cs.wisc.edu/ ~鬼/

PHP Home Page http://www.php.net/

PHP主页:http://www.php.net/

Google search strategy:

谷歌搜索策略:

openoffice scripting pdf linux ://www.google.com/search?q=openoffice%20scripting%20pdf%20linux

openoffice脚本pdf://www.google.com/search?

openoffice print "command line" ://www.google.com/search?q=openoffice%20scripting%20pdf%20linux

openoffice打印“命令行”:// /www.google.com/search?

followed by a search for "command line parameters" from the openoffice.org home page.

然后从openoffice.org主页搜索“命令行参数”。

ref: http://answers.google.com/answers/threadview/id/177241.html

裁判:http://answers.google.com/answers/threadview/id/177241.html

#2


2  

Since PHP is able to execute commands via shell in linux, this could be a good start.

由于PHP能够在linux中通过shell执行命令,这可能是一个良好的开端。