2014-05-28 17:59:44 +02:00
|
|
|
<?php
|
|
|
|
|
include_once 'Sample_Header.php';
|
|
|
|
|
|
|
|
|
|
// New Word document
|
2015-01-01 20:41:42 +04:00
|
|
|
echo date('H:i:s'), ' Create new PhpWord object', EOL;
|
2014-05-28 17:59:44 +02:00
|
|
|
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
|
|
|
|
|
|
|
|
|
// Begin code
|
|
|
|
|
$section = $phpWord->addSection();
|
|
|
|
|
|
|
|
|
|
// Add Field elements
|
|
|
|
|
// See Element/Field.php for all options
|
2015-02-06 22:28:31 +04:00
|
|
|
$section->addText(htmlspecialchars('Date field:', ENT_COMPAT, 'UTF-8'));
|
2015-01-01 20:41:42 +04:00
|
|
|
$section->addField('DATE', array('dateformat' => 'dddd d MMMM yyyy H:mm:ss'), array('PreserveFormat'));
|
2014-05-29 16:21:15 +07:00
|
|
|
|
2015-02-06 22:28:31 +04:00
|
|
|
$section->addText(htmlspecialchars('Page field:', ENT_COMPAT, 'UTF-8'));
|
2015-01-01 20:41:42 +04:00
|
|
|
$section->addField('PAGE', array('format' => 'ArabicDash'));
|
2014-05-29 16:21:15 +07:00
|
|
|
|
2015-02-06 22:28:31 +04:00
|
|
|
$section->addText(htmlspecialchars('Number of pages field:', ENT_COMPAT, 'UTF-8'));
|
2015-01-01 20:41:42 +04:00
|
|
|
$section->addField('NUMPAGES', array('format' => 'Arabic', 'numformat' => '0,00'), array('PreserveFormat'));
|
2014-05-28 17:59:44 +02:00
|
|
|
|
2014-05-29 16:21:15 +07:00
|
|
|
$textrun = $section->addTextRun(array('align' => 'center'));
|
2015-02-06 22:28:31 +04:00
|
|
|
$textrun->addText(htmlspecialchars('This is the date of lunar calendar ', ENT_COMPAT, 'UTF-8'));
|
2015-01-01 20:41:42 +04:00
|
|
|
$textrun->addField('DATE', array('dateformat' => 'd-M-yyyy H:mm:ss'), array('PreserveFormat', 'LunarCalendar'));
|
2015-02-06 22:28:31 +04:00
|
|
|
$textrun->addText(htmlspecialchars(' written in a textrun.', ENT_COMPAT, 'UTF-8'));
|
2014-05-29 16:21:15 +07:00
|
|
|
|
2014-05-28 17:59:44 +02:00
|
|
|
// Save file
|
|
|
|
|
echo write($phpWord, basename(__FILE__, '.php'), $writers);
|
|
|
|
|
if (!CLI) {
|
|
|
|
|
include_once 'Sample_Footer.php';
|
|
|
|
|
}
|