PHP Classes

File: example

Recommend this page to a friend!
  Classes of Raskin Veniamin   PHP Template Docx   example   Download  
File: example
Role: Example script
Content type: text/plain
Description: example
Class: PHP Template Docx
Create Microsoft Word DocX document from template
Author: By
Last change: add commit
Date: 10 years ago
Size: 1,541 bytes
 

Contents

Class file image Download
<?php

/*
Create a file docx. Paste the text into a file {var.title}

{for.list {
1. $text - $val}}

{tbl.products {
#Product Name Cost Count
$p $name $cost $count
}}
 
Save the file.

See an example: https://cloud.mail.ru/public/98f2be9903a0/docx.zip
 */

$root = dirname(__FILE__).DIRECTORY_SEPARATOR;
$fileSrc = $root.'tmp.docx';
$fileOut = 'out.docx';
$assetsExtractDir = './tmp/';

require_once
$root.'VsTemplDocx.php';

//init
$tmp = VsTemplDocx::create(array(
           
'templname'=>$fileSrc,
           
'fileOutPut'=>$fileOut,
           
'tmppatch'=>$assetsExtractDir,
        ));
//add values
$tmp->addParceDoc( array(
           
'title'=>"Title text",
               
           
'list'=>array(
                array(
'text'=>'Label', 'val'=>'101'),
                array(
'text'=>'Eng text', 'val'=>'200'),
                array(
'text'=>'Русский текст', 'val'=>'908'),//string UTF encode
           
),
   
           
'products'=>array(
                array(
'p'=>'1', 'name'=>'TV', 'cost'=>'100.00', 'count'=>'2'),
                array(
'p'=>'2', 'name'=>'Box', 'cost'=>'10.00', 'count'=>'3'),
                array(
'p'=>'3', 'name'=>'KPE', 'cost'=>'100.00', 'count'=>'4'),
                array(
'p'=>'4', 'name'=>'KOB', 'cost'=>'100.00', 'count'=>'200'),
                array(
'p'=>'5', 'name'=>'SOB', 'cost'=>'201.00', 'count'=>'201'),
            ),
 ) );
//render doc
$tmp->createDoc();

//save file
/*
$tmp->createDoc($fileOut, false);
 */
?>