我必须修改上传的.doc或.docx文件在php。我用谷歌搜索过,但我只找到了如何阅读它。我希望word文件是这样的,并在运行时将文本放在该MS Word文件的底部。这是怎么可能的,任何人都知道,请回复或给我示例脚本。
谢谢,
发布于 2010-08-30 01:37:30
我是PHPWord的开发者。您可以使用PHPWord_Template类打开现有的DOCX文件,然后用您的单个文本替换某些文本标记。
或者,您可以打开扩展名为ZipArchive的DOCX文件,然后读/写每个xml文件(document.xml、header.xml、footer.xml等)。你想要的。这个方法就是PHPWord_Template类。;)
发布于 2010-07-30 15:31:14
您可以使用PHPWord。
发布于 2017-11-04 14:35:37
我有同样的要求编辑.doc或.docx文件使用php和我找到了解决方案。我在上面写了一篇文章::http://www.onlinecode.org/update-docx-file-using-php/
if($zip_val->open($full_path) == true)
{
    // In the Open XML Wordprocessing format content is stored.
    // In the document.xml file located in the word directory.
    $key_file_name = 'word/document.xml';
    $message = $zip_val->getFromName($key_file_name);               
    $timestamp = date('d-M-Y H:i:s');
    // this data Replace the placeholders with actual values
    $message = str_replace("client_full_name",      "onlinecode org",       $message);
    $message = str_replace("client_email_address",  "ingo@onlinecode.org",  $message);
    $message = str_replace("date_today",            $timestamp,         $message);      
    $message = str_replace("client_website",        "www.onlinecode.org",   $message);      
    $message = str_replace("client_mobile_number",  "+1999999999",          $message);
    //Replace the content with the new content created above.
    $zip_val->addFromString($key_file_name, $message);
    $zip_val->close();
}https://stackoverflow.com/questions/3369061
复制相似问题