Login   Register  
PHP Classes
elePHPant
Icontem

File: testxls.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Alexander Selifonov  >  PHPExcel wrapper for populating XLS files with user data  >  testxls.php  >  Download  
File: testxls.php
Role: Example script
Content type: text/plain
Description: Using example
Class: PHPExcel wrapper for populating XLS files with user data
Generate Excel spreadsheets from templates
Author: By
Last change: -
Date: 2010-07-07 05:20
Size: 1,542 bytes
 

Contents

Class file image Download
<?php
/**
 @package printform-xls
 @name testxls.php : working with CPrintFormXls class example
 @author Alexander Selifonov < alex [at] selifan (dot) ru >
 @link http://www.selifan.ru
**/
# Attention: PHPExcel.php and all sub-dirs must be in one of folders
#            listed in include_path PHP parameter !!!

require_once('PHPExcel.php');
require_once(
'PHPExcel/IOFactory.php');
require_once(
'PHPExcel/Reader/Excel5.php');
# require_once('PHPExcel/Cell/AdvancedValueBinder.php');

require_once('printform-xls.php');

$excel = new CPrintFormXls(array(
   
'configfile' => 'cfg-test.xml'
  
,'outname' => 'myfile-test.xls'
));

$data = array(
   
'last_name'  => 'Smirnoff'
  
,'first_name' => 'Ivan'
  
,'birthdate'  => '1970-04-18'
  
,'address'    => 'Russia, Moscow, Usacheva street, 33-999'
  
,'resident'   => 1
);
$excel->AddData($data);

$excel->SetAuthor('Shurik !');
$excel->SetDescription('&#207;&#240;&#238;&#226;&#229;&#240;&#234;&#224; &#240;&#224;&#225;&#238;&#242;&#251; &#234;&#235;&#224;&#241;&#241;&#224; CPrintFormXls, &#242;&#224;&#237;&#246;&#243;&#254;&#242; &#226;&#241;&#229; !');

$excel->ProtectSheets(true,'mypassword');
$excel->ProtectBook(true,'mypassword'); # doesn't work ???

# Let's manupulate XLS object manually
$xlsobj $excel->GetXlsObject();
$xlsobj->getSheet(0)->setCellValueByColumnAndRow(317'This text inserted outside class !');

$ok $excel->Render();

if(!
$ok) echo $excel->GetErrorMessage();

function 
AddBraces($param) {
    return 
"[ $param ]";
}