PHPWord/samples/Sample_02_TabStops.php

40 lines
1.2 KiB
PHP
Raw Normal View History

2013-12-15 14:35:18 +01:00
<?php
2014-03-15 22:39:57 +07:00
include_once 'Sample_Header.php';
2013-12-15 14:35:18 +01:00
// New Word Document
2015-01-01 20:41:42 +04:00
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
2013-12-15 14:35:18 +01:00
2016-06-04 20:06:37 +04:00
// Define styles
$multipleTabsStyleName = 'multipleTab';
2015-01-01 20:41:42 +04:00
$phpWord->addParagraphStyle(
2016-06-04 20:06:37 +04:00
$multipleTabsStyleName,
2015-01-01 20:41:42 +04:00
array(
'tabs' => array(
new \PhpOffice\PhpWord\Style\Tab('left', 1550),
new \PhpOffice\PhpWord\Style\Tab('center', 3200),
new \PhpOffice\PhpWord\Style\Tab('right', 5300),
)
)
);
2016-06-04 20:06:37 +04:00
$rightTabStyleName = 'rightTab';
$phpWord->addParagraphStyle($rightTabStyleName, array('tabs' => array(new \PhpOffice\PhpWord\Style\Tab('right', 9090))));
$leftTabStyleName = 'centerTab';
$phpWord->addParagraphStyle($leftTabStyleName, array('tabs' => array(new \PhpOffice\PhpWord\Style\Tab('center', 4680))));
2013-12-15 14:35:18 +01:00
// New portrait section
$section = $phpWord->addSection();
2013-12-15 14:35:18 +01:00
// Add listitem elements
2016-06-04 20:06:37 +04:00
$section->addText("Multiple Tabs:\tOne\tTwo\tThree", null, $multipleTabsStyleName);
$section->addText("Left Aligned\tRight Aligned", null, $rightTabStyleName);
$section->addText("\tCenter Aligned", null, $leftTabStyleName);
2013-12-15 14:35:18 +01:00
// Save file
2014-04-12 10:12:24 +07:00
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {
include_once 'Sample_Footer.php';
}