-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathexample.php
25 lines (14 loc) · 1.2 KB
/
example.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
<?php
require("phpDocx.php");
$phpdocx = new phpdocx("template.docx");
//$phpdocx->addImage("dog1","./example_dog.jpg");
$phpdocx->assignToHeader("#HEADER1#","Header 1"); // basic field mapping to header
$phpdocx->assignToFooter("#FOOTER1#","Footer 1"); // basic field mapping to footer
$phpdocx->assign("#TITLE1#","Pet shop list"); // basic field mapping
$phpdocx->assignBlock("members",array(array("#NAME#"=>"John","#SURNAME#"=>"DOE"),array("#NAME#"=>"Jane","#SURNAME#"=>"DOE"))); // this would replicate two members block with the associated values
$phpdocx->assignNestedBlock("pets",array(array("#PETNAME#"=>"Rex")),array("members"=>1)); // would create a block pets for john doe with the name rex
$phpdocx->assignNestedBlock("pets",array(array("#PETNAME#"=>"Rox")),array("members"=>2)); // would create a block pets for jane doe with the name rox
$phpdocx->assignNestedBlock("toys",array(array("#TOYNAME#"=>"Ball"),array("#TOYNAME#"=>"Frisbee"),array("#TOYNAME#"=>"Box")),array("members"=>1,"pets"=>1)); // would create a block toy for rex
$phpdocx->assignNestedBlock("toys",array(array("#TOYNAME#"=>"Frisbee")),array("members"=>2,"pets"=>1)); // would create a block toy for rox
$phpdocx->save("pets.docx");
?>