No Description

Sample_34_SDT.php 795B

1234567891011121314151617181920212223242526
  1. <?php
  2. include_once 'Sample_Header.php';
  3. // New Word document
  4. echo date('H:i:s'), ' Create new PhpWord object', EOL;
  5. $phpWord = new \PhpOffice\PhpWord\PhpWord();
  6. $section = $phpWord->addSection();
  7. $textrun = $section->addTextRun();
  8. $textrun->addText(htmlspecialchars('Combobox: '));
  9. $textrun->addSDT('comboBox')->setListItems(array('1' => 'Choice 1', '2' => 'Choice 2'));
  10. $textrun = $section->addTextRun();
  11. $textrun->addText(htmlspecialchars('Date: '));
  12. $textrun->addSDT('date');
  13. $textrun = $section->addTextRun();
  14. $textrun->addText(htmlspecialchars('Drop down list: '));
  15. $textrun->addSDT('dropDownList')->setListItems(array('1' => 'Choice 1', '2' => 'Choice 2'));
  16. // Save file
  17. echo write($phpWord, basename(__FILE__, '.php'), $writers);
  18. if (!CLI) {
  19. include_once 'Sample_Footer.php';
  20. }