Login   Register  
PHP Classes
elePHPant
Icontem

File: example

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of vench  >  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: comments
Date: 1 year ago
Size: 1,478 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.
 */

$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); 
 */
?>