-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSample_34_SDT.php
More file actions
26 lines (20 loc) · 858 Bytes
/
Sample_34_SDT.php
File metadata and controls
26 lines (20 loc) · 858 Bytes
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
<?php
include_once 'Sample_Header.php';
// New Word document
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
$textrun = $section->addTextRun();
$textrun->addText(htmlspecialchars('Combobox: ', ENT_COMPAT, 'UTF-8'));
$textrun->addSDT('comboBox')->setListItems(array('1' => 'Choice 1', '2' => 'Choice 2'));
$textrun = $section->addTextRun();
$textrun->addText(htmlspecialchars('Date: ', ENT_COMPAT, 'UTF-8'));
$textrun->addSDT('date');
$textrun = $section->addTextRun();
$textrun->addText(htmlspecialchars('Drop down list: ', ENT_COMPAT, 'UTF-8'));
$textrun->addSDT('dropDownList')->setListItems(array('1' => 'Choice 1', '2' => 'Choice 2'));
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {
include_once 'Sample_Footer.php';
}