Location: PHPKode > scripts > PHPExcel wrapper for populating XLS files with user data > testxls.php
<?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(3, 17, 'This text inserted outside class !');

$ok = $excel->Render();

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

function AddBraces($param) {
    return "[ $param ]";
}
Return current item: PHPExcel wrapper for populating XLS files with user data