<bdo id='WBJxR'></bdo><ul id='WBJxR'></ul>
<i id='WBJxR'><tr id='WBJxR'><dt id='WBJxR'><q id='WBJxR'><span id='WBJxR'><b id='WBJxR'><form id='WBJxR'><ins id='WBJxR'></ins><ul id='WBJxR'></ul><sub id='WBJxR'></sub></form><legend id='WBJxR'></legend><bdo id='WBJxR'><pre id='WBJxR'><center id='WBJxR'></center></pre></bdo></b><th id='WBJxR'></th></span></q></dt></tr></i><div id='WBJxR'><tfoot id='WBJxR'></tfoot><dl id='WBJxR'><fieldset id='WBJxR'></fieldset></dl></div>

    <tfoot id='WBJxR'></tfoot>

    <small id='WBJxR'></small><noframes id='WBJxR'>

    1. <legend id='WBJxR'><style id='WBJxR'><dir id='WBJxR'><q id='WBJxR'></q></dir></style></legend>

    2. 用 PHP 读/写 MS Word 文件

      时间:2023-07-16
      <legend id='7lFwc'><style id='7lFwc'><dir id='7lFwc'><q id='7lFwc'></q></dir></style></legend>
    3. <tfoot id='7lFwc'></tfoot>

        <tbody id='7lFwc'></tbody>

          <small id='7lFwc'></small><noframes id='7lFwc'>

          <i id='7lFwc'><tr id='7lFwc'><dt id='7lFwc'><q id='7lFwc'><span id='7lFwc'><b id='7lFwc'><form id='7lFwc'><ins id='7lFwc'></ins><ul id='7lFwc'></ul><sub id='7lFwc'></sub></form><legend id='7lFwc'></legend><bdo id='7lFwc'><pre id='7lFwc'><center id='7lFwc'></center></pre></bdo></b><th id='7lFwc'></th></span></q></dt></tr></i><div id='7lFwc'><tfoot id='7lFwc'></tfoot><dl id='7lFwc'><fieldset id='7lFwc'></fieldset></dl></div>

          • <bdo id='7lFwc'></bdo><ul id='7lFwc'></ul>

              1. 本文介绍了用 PHP 读/写 MS Word 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                是否可以在不使用 COM 对象的情况下在 PHP 中读取和写入 Word(2003 和 2007)文件?我知道我可以:

                Is it possible to read and write Word (2003 and 2007) files in PHP without using a COM object? I know that I can:

                $file = fopen('c:file.doc', 'w+');
                fwrite($file, $text);
                fclose();
                

                但 Word 会将其作为 HTML 文件而不是本机 .doc 文件读取.

                but Word will read it as an HTML file not a native .doc file.

                推荐答案

                读取二进制 Word 文档将涉及根据已发布的 DOC 格式文件格式规范创建解析器.我认为这不是真正可行的解决方案.

                Reading binary Word documents would involve creating a parser according to the published file format specifications for the DOC format. I think this is no real feasible solution.

                您可以使用 Microsoft Office XML 格式来读取和写入 Word 文件 -这与 2003 和 2007 版本的 Word 兼容.为了阅读,您必须确保以正确的格式保存 Word 文档(在 Word 2007 中称为 Word 2003 XML 文档).对于编写,您只需遵循公开可用的 XML 模式.我从未使用这种格式从 PHP 写出 Office 文档,但我使用它来读取 Excel 工作表(自然保存为 XML-Spreadsheet 2003)并在网页上显示其数据.由于文件是简单的 XML 数据,因此在其中导航并找出如何提取所需的数据没有问题.

                You could use the Microsoft Office XML formats for reading and writing Word files - this is compatible with the 2003 and 2007 version of Word. For reading you have to ensure that the Word documents are saved in the correct format (it's called Word 2003 XML-Document in Word 2007). For writing you just have to follow the openly available XML schema. I've never used this format for writing out Office documents from PHP, but I'm using it for reading in an Excel worksheet (naturally saved as XML-Spreadsheet 2003) and displaying its data on a web page. As the files are plainly XML data it's no problem to navigate within and figure out how to extract the data you need.

                另一个选项 - 仅适用于 Word 2007 的选项(如果您的 Word 2003 中未安装 OpenXML 文件格式) - 将使用 OpenXML.正如 databyss 指出的那样 此处 DOCX 文件格式只是包含 XML 文件的 ZIP 存档.MSDN 上有很多关于 OpenXML 文件格式的资源,所以你应该能够弄清楚如何读取你想要的数据.我认为写作会复杂得多 - 这仅取决于您将投入多少时间.

                The other option - a Word 2007 only option (if the OpenXML file formats are not installed in your Word 2003) - would be to ressort to OpenXML. As databyss pointed out here the DOCX file format is just a ZIP archive with XML files included. There are a lot of resources on MSDN regarding the OpenXML file format, so you should be able to figure out how to read the data you want. Writing will be much more complicated I think - it just depends on how much time you'll invest.

                也许你可以看看 PHPExcel 这是一个能够编写的库到 Excel 2007 文件并使用 OpenXML 标准从 Excel 2007 文件中读取.在尝试读取和编写 OpenXML Word 文档时,您可以了解所涉及的工作.

                Perhaps you can have a look at PHPExcel which is a library able to write to Excel 2007 files and read from Excel 2007 files using the OpenXML standard. You could get an idea of the work involved when trying to read and write OpenXML Word documents.

                这篇关于用 PHP 读/写 MS Word 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何将 oAuth 与 Guzzle 5(或者,更好,与 Guzzle 6)一起使用 下一篇:如何从word文件中提取文本.doc,docx,.xlsx,.pptx php

                相关文章

              2. <tfoot id='YFgq3'></tfoot>

                  <small id='YFgq3'></small><noframes id='YFgq3'>

                    <bdo id='YFgq3'></bdo><ul id='YFgq3'></ul>

                    <legend id='YFgq3'><style id='YFgq3'><dir id='YFgq3'><q id='YFgq3'></q></dir></style></legend>

                    <i id='YFgq3'><tr id='YFgq3'><dt id='YFgq3'><q id='YFgq3'><span id='YFgq3'><b id='YFgq3'><form id='YFgq3'><ins id='YFgq3'></ins><ul id='YFgq3'></ul><sub id='YFgq3'></sub></form><legend id='YFgq3'></legend><bdo id='YFgq3'><pre id='YFgq3'><center id='YFgq3'></center></pre></bdo></b><th id='YFgq3'></th></span></q></dt></tr></i><div id='YFgq3'><tfoot id='YFgq3'></tfoot><dl id='YFgq3'><fieldset id='YFgq3'></fieldset></dl></div>