29 error_reporting(E_ALL);
30 ini_set(
'display_errors', TRUE);
31 ini_set(
'display_startup_errors', TRUE);
33 define(
'EOL',(PHP_SAPI ==
'cli') ?
PHP_EOL :
'<br />');
35 date_default_timezone_set(
'Europe/London');
38 require_once dirname(__FILE__) .
'/../Classes/PHPExcel.php';
42 echo date(
'H:i:s') ,
" Create new PHPExcel object" ,
EOL;
47 $objPHPExcel->getProperties()->setCreator(
"Maarten Balliauw")
48 ->setLastModifiedBy(
"Maarten Balliauw")
49 ->setTitle(
"Office 2007 XLSX Test Document")
50 ->setSubject(
"Office 2007 XLSX Test Document")
51 ->setDescription(
"Test document for Office 2007 XLSX, generated using PHP classes.")
52 ->setKeywords(
"office 2007 openxml php")
53 ->setCategory(
"Test result file");
59 $objPHPExcel->getActiveSheet()->setCellValue(
'A1',
'Description')
60 ->setCellValue(
'B1',
'Amount');
62 $objPHPExcel->getActiveSheet()->setCellValue(
'A2',
'Paycheck received')
63 ->setCellValue(
'B2', 100);
65 $objPHPExcel->getActiveSheet()->setCellValue(
'A3',
'Cup of coffee bought')
66 ->setCellValue(
'B3', -1.5);
68 $objPHPExcel->getActiveSheet()->setCellValue(
'A4',
'Cup of coffee bought')
69 ->setCellValue(
'B4', -1.5);
71 $objPHPExcel->getActiveSheet()->setCellValue(
'A5',
'Cup of tea bought')
72 ->setCellValue(
'B5', -1.2);
74 $objPHPExcel->getActiveSheet()->setCellValue(
'A6',
'Found some money')
75 ->setCellValue(
'B6', 8);
77 $objPHPExcel->getActiveSheet()->setCellValue(
'A7',
'Total:')
78 ->setCellValue(
'B7',
'=SUM(B2:B6)');
83 $objPHPExcel->getActiveSheet()->getColumnDimension(
'A')->setWidth(30);
84 $objPHPExcel->getActiveSheet()->getColumnDimension(
'B')->setWidth(12);
93 ->addCondition(
'400');
122 echo date(
'H:i:s') ,
" Duplicate the conditional formatting across a range of cells" ,
EOL;
123 $objPHPExcel->getActiveSheet()->duplicateConditionalStyle(
124 $objPHPExcel->getActiveSheet()->getStyle(
'B2')->getConditionalStyles(),
131 $objPHPExcel->getActiveSheet()->getStyle(
'A1:B1')->getFont()->setBold(
true);
133 $objPHPExcel->getActiveSheet()->getStyle(
'A7:B7')->getFont()->setBold(
true);
139 $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader(
'&L&BPersonal cash register&RPrinted on &D');
140 $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter(
'&L&B' .
$objPHPExcel->getProperties()->getTitle() .
'&RPage &P of &N');
163 $objWriter->save(str_replace(
'.php',
'.xlsx', __FILE__));
167 echo date(
'H:i:s') ,
" File written to " , str_replace(
'.php',
'.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) ,
EOL;
170 echo date(
'H:i:s') ,
" Write to Excel5 format" ,
EOL;
171 $callStartTime = microtime(
true);
174 $objWriter->save(str_replace(
'.php',
'.xls', __FILE__));
178 echo date(
'H:i:s') ,
" File written to " , str_replace(
'.php',
'.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) ,
EOL;
179 echo 'Call time to write Workbook was ' , sprintf(
'%.4f',
$callTime) ,
" seconds" ,
EOL;
181 echo date(
'H:i:s') ,
' Current memory usage: ' , (memory_get_usage(
true) / 1024 / 1024) ,
" MB" , EOL;
185 echo date(
'H:i:s') ,
" Peak memory usage: " , (memory_get_peak_usage(
true) / 1024 / 1024) ,
" MB" , EOL;
189 echo 'File has been created in ' , getcwd() ,
EOL;
const OPERATOR_GREATERTHANOREQUAL
static createWriter(PHPExcel $phpExcel, $writerType='')
Create PHPExcel_Writer_IWriter.
if($is_dev) echo "Review changes write something in WHATSNEW and and then commit with log PHP_EOL
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
const ORIENTATION_PORTRAIT