No Description

Sample_02_TabStops.php 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. // Ads styles
  7. $phpWord->addParagraphStyle(
  8. 'multipleTab',
  9. array(
  10. 'tabs' => array(
  11. new \PhpOffice\PhpWord\Style\Tab('left', 1550),
  12. new \PhpOffice\PhpWord\Style\Tab('center', 3200),
  13. new \PhpOffice\PhpWord\Style\Tab('right', 5300),
  14. )
  15. )
  16. );
  17. $phpWord->addParagraphStyle(
  18. 'rightTab',
  19. array('tabs' => array(new \PhpOffice\PhpWord\Style\Tab('right', 9090)))
  20. );
  21. $phpWord->addParagraphStyle(
  22. 'centerTab',
  23. array('tabs' => array(new \PhpOffice\PhpWord\Style\Tab('center', 4680)))
  24. );
  25. // New portrait section
  26. $section = $phpWord->addSection();
  27. // Add listitem elements
  28. $section->addText(htmlspecialchars("Multiple Tabs:\tOne\tTwo\tThree"), null, 'multipleTab');
  29. $section->addText(htmlspecialchars("Left Aligned\tRight Aligned"), null, 'rightTab');
  30. $section->addText(htmlspecialchars("\tCenter Aligned"), null, 'centerTab');
  31. // Save file
  32. echo write($phpWord, basename(__FILE__, '.php'), $writers);
  33. if (!CLI) {
  34. include_once 'Sample_Footer.php';
  35. }