forked from PHPOffice/PHPWord
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sample_34_SDT.php
33 lines (27 loc) · 1 KB
/
Sample_34_SDT.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
include_once 'Sample_Header.php';
// New Word document
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
// New section
$section = $phpWord->addSection();
$textrun = $section->addTextRun();
$textrun->addText('Combobox: ');
$textrun->addSDT('comboBox')->setListItems(array('1' => 'Choice 1', '2' => 'Choice 2'));
$textrun = $section->addTextRun();
$textrun->addText('Date: ');
$textrun->addSDT('date');
$textrun->addTextBreak(1);
$textrun->addText('Date with pre set value: ');
$textrun->addSDT('date')->setValue('03/30/2017');
$textrun->addTextBreak(1);
$textrun->addText('Date with pre set value: ');
$textrun->addSDT('date')->setValue('30.03.2017');
$textrun = $section->addTextRun();
$textrun->addText('Drop down list: ');
$textrun->addSDT('dropDownList')->setListItems(array('1' => 'Choice 1', '2' => 'Choice 2'))->setValue('Choice 1');
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {
include_once 'Sample_Footer.php';
}