如何使用 PHPWord 在 PHP 中设置制表符位置

How to set tab position in PHP with PHPWord

我想在任意行设置tab位置 http://www.phpdocx.com/img/sampleScripts/WordContent/example_addText_4.png

phpword 示例中有一个示例,请参阅 php word samples - tabs

为方便起见,将相同的示例代码内容复制到此处:

// Ads styles
$phpWord->addParagraphStyle(
    'multipleTab',
    array(
        'tabs' => array(
            new \PhpOffice\PhpWord\Style\Tab('left', 1550),
            new \PhpOffice\PhpWord\Style\Tab('center', 3200),
            new \PhpOffice\PhpWord\Style\Tab('right', 5300),
        )
    )
);

$phpWord->addParagraphStyle(
    'rightTab',
    array('tabs' => array(new \PhpOffice\PhpWord\Style\Tab('right', 9090)))
);

$phpWord->addParagraphStyle(
    'centerTab',
    array('tabs' => array(new \PhpOffice\PhpWord\Style\Tab('center', 4680)))
);

// New portrait section
$section = $phpWord->addSection();

// Add listitem elements
$section->addText(htmlspecialchars("Multiple Tabs:\tOne\tTwo\tThree"), null, 'multipleTab');
$section->addText(htmlspecialchars("Left Aligned\tRight Aligned"), null, 'rightTab');
$section->addText(htmlspecialchars("\tCenter Aligned"), null, 'centerTab');