-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphpWordExample.php
More file actions
34 lines (24 loc) · 1.05 KB
/
phpWordExample.php
File metadata and controls
34 lines (24 loc) · 1.05 KB
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
34
<?php
require_once('vendor/autoload.php');
require_once ('CustomContainer/CustomContainer.php');
$newDocumentWithSection = new \PhpOffice\PhpWord\PhpWord();
$newSection = $newDocumentWithSection->addSection();
$newTitle = $newSection->addTitle('someTitle');
$newTable = $newSection->addTable([
'borderSize' => 12,
'borderColor' => 'green',
'width' => 6000,
'unit' => PhpOffice\PhpWord\SimpleType\TblWidth::TWIP
]);
$newTable->addRow();
$newTable->addCell(150)->addText('Cell A1');
$newTable->addCell(150)->addText('Cell A2');
$newTable->addCell(150)->addText('Cell A3');
$newTable->addRow();
$newTable->addCell(150)->addText('Cell B1');
$newTable->addCell(150)->addText('Cell B2');
$newTable->addCell(150)->addText('Cell B3');
$newCustomContainerWithSection = new \CustomContainer\Container($newSection);
$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('templateWithGeneratedSection.docx');
$templateProcessor->setComplexBlock('macro', $newCustomContainerWithSection);
$templateProcessor->saveAs('DocumentWithGeneratedSection.docx');