簡體   English   中英

從 PHP ms sql html 表生成 docx 文檔

[英]Generating docx document from PHP ms sql html table

我有一張表,我想將其導出為 docx 文檔,任何人都可以建議一種方法,

我在左側附上了網站的圖片,右側是我想將其輸出到 docx 中的文檔。

謝謝

https://www.phpdocx.com/ 上使用 PHPDOCx。 示例代碼:

require_once 'pathToPHPDocX/classes/CreateDocx.inc';

$docx = new CreateDocx();

$html='<p>This is a simple paragraph with <strong>text in bold</strong>.</p>
<p>Now we include a list:</p>
<ul>
    <li>First item.</li>
    <li>Second item with subitems:
        <ul>
            <li>First subitem.</li>
            <li>Second subitem.</li>
        </ul>
    </li>
    <li>Third subitem.</li>
</ul>
<p>And now a table:</p>
<table>
    <tbody><tr>
        <td>Cell 1 1</td>
        <td>Cell 1 2</td>
    </tr>
    <tr>
        <td>Cell 2 1</td>
        <td>Cell 2 2</td>
    </tr>
</tbody></table>';

$docx->embedHTML($html);

$docx->createDocx('simpleHTML');

如果要將外部頁面轉換為 html,請在變量中使用 file_get_contents 函數添加內容並將其發送到 embedHTML

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM