php使用PhpWord实现生成word文档并转换成html网页代码

代码语言:php

所属分类:其他

代码描述:php使用PhpWord实现生成word文档并转换成html网页代码

代码标签: php PhpWord word html 文档

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<?php
require('../lib/php/vendor/autoload.php');


// Creating the new document...
$phpWord = new \PhpOffice\PhpWord\PhpWord();

/* Note: any element you append to a document must reside inside of a Section. */

// Adding an empty Section to the document...
$section = $phpWord->addSection();
// Adding Text element to the Section having font styled by default...
$section->addText(
    '你好,bfw. '
        . 'The important thing is not to stop questioning." '
        . '(Albert Einstein)'
);

/*
 * Note: it's possible to customize font style of the Text element you add in three ways:
 * - inline;
 * - using named font style (new font style object will be implicitly created);
 * - using explicitly created font style object.
 */

// Adding Text element with font customized inline...
$section->addText(
    '"Great achievement is usually born of great sacrifice, '
        . 'and is never the result of selfishness." '
        . '(Napoleon Hill)',
    array('name' => 'Tahoma', 'size' => 10)
);

// Adding Text element with font customized using named font style...
$fontStyleName = 'oneUserDefinedStyle';
$phpWord->addFontStyle(
    $fontStyleName,
    array('.........完整代码请登录后点击上方下载按钮下载查看

网友评论0