代码仓库:https://github.com/cshaptx4869/html2word


1、进入/dayrui目录

2、使用命令行安装类

composer require cshaptx4869/html2word


3、需要将vendor目录命名为Vendor(首字母大写)

4、新建html测试文件

dayrui/App/Demo/doc.html

    <!doctype html>
    <html lang="en"><head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>html template</title>
   </head>
   <body>
    <h1>中文的标题,技术无止境,一直在路上</h1>
    <p>p是可以分段的. 使用PHP将html转word</p>
    <p>再分一段 使用PHP将html转word</p>
    <p>还分一段,下面加个图片</p>
   </body>
   </html>

4、新建控制器文件:

dayrui/App/Demo/Controllers/Doc.php


5、访问url,即可下载doc文件

index.php?s=demo&c=doc&m=index

本文地址:https://m.xunruicms.com/doc/1000.html