29error_reporting(E_ALL);
30ini_set(
'display_errors', TRUE);
31ini_set(
'display_startup_errors', TRUE);
33define(
'EOL',(PHP_SAPI ==
'cli') ?
PHP_EOL :
'<br />');
35date_default_timezone_set(
'Europe/London');
38require_once dirname(__FILE__) .
'/../Classes/PHPExcel/IOFactory.php';
42echo
date(
'H:i:s') ,
" Load from Excel5 template" ,
EOL;
49echo
date(
'H:i:s') ,
" Add new data to the template" ,
EOL;
50$data = array(array(
'title' =>
'Excel for dummies',
54 array(
'title' =>
'PHP for dummies',
58 array(
'title' =>
'Inside OOP',
67foreach(
$data as
$r => $dataRow) {
72 ->setCellValue(
'B'.
$row, $dataRow[
'title'])
73 ->setCellValue(
'C'.
$row, $dataRow[
'price'])
74 ->setCellValue(
'D'.
$row, $dataRow[
'quantity'])
80echo
date(
'H:i:s') ,
" Write to Excel5 format" ,
EOL;
82$objWriter->save(str_replace(
'.php',
'.xls', __FILE__));
83echo
date(
'H:i:s') ,
" File written to " , str_replace(
'.php',
'.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) ,
EOL;
90echo
date(
'H:i:s') ,
" Done writing file" ,
EOL;
91echo
'File has been created in ' , getcwd() ,
EOL;
memory_get_peak_usage(true)/1024/1024)
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
An exception for terminatinating execution or to throw for unit testing.
static createWriter(PHPExcel $phpExcel, $writerType='')
Create PHPExcel_Writer_IWriter.
static createReader($readerType='')
Create PHPExcel_Reader_IReader.
static PHPToExcel($dateValue=0, $adjustToTimezone=FALSE, $timezone=NULL)
Convert a date from PHP to Excel.