gpt4 book ai didi

php - 解析和生成 Microsoft Office 2007 文件(.docx、.xlsx、.pptx)

转载 作者:IT王子 更新时间:2023-10-29 00:10:52 25 4
gpt4 key购买 nike

我有一个 Web 项目,我必须从用户提供的文档中导入文本和图像,其中一种可能的格式是 Microsoft Office 2007。还需要生成这种格式的文档。

服务器运行 CentOS 5.2 并安装了 PHP/Perl/Python。如果需要,我可以执行本地二进制文件和 shell 脚本。我们使用 Apache 2.2,但一旦它上线就会切换到 Nginx。

我有哪些选择?有人有这方面的经验吗?

最佳答案

Office 2007 文件格式是开放的并且well documented .粗略地说,所有以“x”结尾的新文件格式都是 zip 压缩的 XML 文档。例如:

To open a Word 2007 XML file Create a temporary folder in which to store the file and its parts.

Save a Word 2007 document, containing text, pictures, and other elements, as a .docx file.

Add a .zip extension to the end of the file name.

Double-click the file. It will open in the ZIP application. You can see the parts that comprise the file.

Extract the parts to the folder that you created previously.

其他文件格式大致相似。我还不知道有任何开源库可以与它们交互——但根据您的具体要求,阅读和编​​写简单的文档看起来并不太难。当然,它应该比旧格式容易得多。

如果您需要阅读较旧的格式,OpenOffice 有一个 API,可以读写 Office 2003 和较旧的文档,或多或少会成功。

关于php - 解析和生成 Microsoft Office 2007 文件(.docx、.xlsx、.pptx),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/173246/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com