【问题标题】:How to detect a EOF (End Of File) character when read word file with PHPWord library使用 PHPWord 库读取 word 文件时如何检测 EOF(文件结尾)字符
【发布时间】:2019-07-24 16:22:17
【问题描述】:

我用 PHPWord 库读取 word 文件

$objReader = \PhpOffice\PhpWord\IOFactory::createReader('Word2007');
$phpWord = $objReader->load($_FILES["fileToUpload"]['tmp_name'], "UTF-8");

foreach ($phpWord->getSections() as $section) {
    $arrays = $section->getElements();
    foreach ($arrays as $e) {
        if (get_class($e) === 'PhpOffice\PhpWord\Element\TextRun') {
            foreach($e->getElements() as $text) {
                echo $text->getText();
            }
        }
    }

问题是我无法检测到 EOF 字符,我花了很多时间来解决这个问题,但根本没有工作。

【问题讨论】:

    标签: php phpword phpoffice


    【解决方案1】:

    使用驱动程序阅读时您不会收到任何EOF

    ...如果没有驱动程序,您将无法读取该格式。

    *.docx 甚至包含几个EOF;每个压缩的 XML 文件一个。


    假设$phpWord->getSections() 的结尾与EOF 相似是保存的。

    【讨论】:

      猜你喜欢
      • 2016-08-13
      • 2017-02-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-22
      • 1970-01-01
      • 1970-01-01
      • 2013-08-02
      相关资源
      最近更新 更多