diff --git a/Tests/13calculation.php b/Tests/13calculation.php index 081a007..3d1de90 100644 --- a/Tests/13calculation.php +++ b/Tests/13calculation.php @@ -27,6 +27,11 @@ /** Error reporting */ error_reporting(E_ALL); +ini_set('display_errors', TRUE); +ini_set('display_startup_errors', TRUE); +date_default_timezone_set('Europe/London'); + +define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '
'); date_default_timezone_set('Europe/London'); @@ -35,177 +40,178 @@ require_once '../Classes/PHPExcel.php'; // List functions -echo date('H:i:s') , " List implemented functions" , PHP_EOL; +echo date('H:i:s') , " List implemented functions" , EOL; $objCalc = PHPExcel_Calculation::getInstance(); print_r($objCalc->listFunctionNames()); // Create new PHPExcel object -echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL; +echo date('H:i:s') , " Create new PHPExcel object" , EOL; $objPHPExcel = new PHPExcel(); // Add some data, we will use some formulas here -echo date('H:i:s') , " Add some data and formulas" , PHP_EOL; -$objPHPExcel->getActiveSheet()->setCellValue('A14', 'Count:'); -$objPHPExcel->getActiveSheet()->setCellValue('A15', 'Sum:'); -$objPHPExcel->getActiveSheet()->setCellValue('A16', 'Max:'); -$objPHPExcel->getActiveSheet()->setCellValue('A17', 'Min:'); -$objPHPExcel->getActiveSheet()->setCellValue('A18', 'Average:'); -$objPHPExcel->getActiveSheet()->setCellValue('A19', 'Median:'); -$objPHPExcel->getActiveSheet()->setCellValue('A20', 'Mode:'); +echo date('H:i:s') , " Add some data and formulas" , EOL; +$objPHPExcel->getActiveSheet()->setCellValue('A14', 'Count:') + ->setCellValue('A15', 'Sum:') + ->setCellValue('A16', 'Max:') + ->setCellValue('A17', 'Min:') + ->setCellValue('A18', 'Average:') + ->setCellValue('A19', 'Median:') + ->setCellValue('A20', 'Mode:'); -$objPHPExcel->getActiveSheet()->setCellValue('A22', 'CountA:'); -$objPHPExcel->getActiveSheet()->setCellValue('A23', 'MaxA:'); -$objPHPExcel->getActiveSheet()->setCellValue('A24', 'MinA:'); +$objPHPExcel->getActiveSheet()->setCellValue('A22', 'CountA:') + ->setCellValue('A23', 'MaxA:') + ->setCellValue('A24', 'MinA:'); -$objPHPExcel->getActiveSheet()->setCellValue('A26', 'StDev:'); -$objPHPExcel->getActiveSheet()->setCellValue('A27', 'StDevA:'); -$objPHPExcel->getActiveSheet()->setCellValue('A28', 'StDevP:'); -$objPHPExcel->getActiveSheet()->setCellValue('A29', 'StDevPA:'); +$objPHPExcel->getActiveSheet()->setCellValue('A26', 'StDev:') + ->setCellValue('A27', 'StDevA:') + ->setCellValue('A28', 'StDevP:') + ->setCellValue('A29', 'StDevPA:'); -$objPHPExcel->getActiveSheet()->setCellValue('A31', 'DevSq:'); -$objPHPExcel->getActiveSheet()->setCellValue('A32', 'Var:'); -$objPHPExcel->getActiveSheet()->setCellValue('A33', 'VarA:'); -$objPHPExcel->getActiveSheet()->setCellValue('A34', 'VarP:'); -$objPHPExcel->getActiveSheet()->setCellValue('A35', 'VarPA:'); +$objPHPExcel->getActiveSheet()->setCellValue('A31', 'DevSq:') + ->setCellValue('A32', 'Var:') + ->setCellValue('A33', 'VarA:') + ->setCellValue('A34', 'VarP:') + ->setCellValue('A35', 'VarPA:'); $objPHPExcel->getActiveSheet()->setCellValue('A37', 'Date:'); -$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Range 1'); -$objPHPExcel->getActiveSheet()->setCellValue('B2', 2); -$objPHPExcel->getActiveSheet()->setCellValue('B3', 8); -$objPHPExcel->getActiveSheet()->setCellValue('B4', 10); -$objPHPExcel->getActiveSheet()->setCellValue('B5', True); -$objPHPExcel->getActiveSheet()->setCellValue('B6', False); -$objPHPExcel->getActiveSheet()->setCellValue('B7', 'Text String'); -$objPHPExcel->getActiveSheet()->setCellValue('B9', '22'); -$objPHPExcel->getActiveSheet()->setCellValue('B10', 4); -$objPHPExcel->getActiveSheet()->setCellValue('B11', 6); -$objPHPExcel->getActiveSheet()->setCellValue('B12', 12); +$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Range 1') + ->setCellValue('B2', 2) + ->setCellValue('B3', 8) + ->setCellValue('B4', 10) + ->setCellValue('B5', True) + ->setCellValue('B6', False) + ->setCellValue('B7', 'Text String') + ->setCellValue('B9', '22') + ->setCellValue('B10', 4) + ->setCellValue('B11', 6) + ->setCellValue('B12', 12); -$objPHPExcel->getActiveSheet()->setCellValue('B14', '=COUNT(B2:B12)'); -$objPHPExcel->getActiveSheet()->setCellValue('B15', '=SUM(B2:B12)'); -$objPHPExcel->getActiveSheet()->setCellValue('B16', '=MAX(B2:B12)'); -$objPHPExcel->getActiveSheet()->setCellValue('B17', '=MIN(B2:B12)'); -$objPHPExcel->getActiveSheet()->setCellValue('B18', '=AVERAGE(B2:B12)'); -$objPHPExcel->getActiveSheet()->setCellValue('B19', '=MEDIAN(B2:B12)'); -$objPHPExcel->getActiveSheet()->setCellValue('B20', '=MODE(B2:B12)'); +$objPHPExcel->getActiveSheet()->setCellValue('B14', '=COUNT(B2:B12)') + ->setCellValue('B15', '=SUM(B2:B12)') + ->setCellValue('B16', '=MAX(B2:B12)') + ->setCellValue('B17', '=MIN(B2:B12)') + ->setCellValue('B18', '=AVERAGE(B2:B12)') + ->setCellValue('B19', '=MEDIAN(B2:B12)') + ->setCellValue('B20', '=MODE(B2:B12)'); -$objPHPExcel->getActiveSheet()->setCellValue('B22', '=COUNTA(B2:B12)'); -$objPHPExcel->getActiveSheet()->setCellValue('B23', '=MAXA(B2:B12)'); -$objPHPExcel->getActiveSheet()->setCellValue('B24', '=MINA(B2:B12)'); +$objPHPExcel->getActiveSheet()->setCellValue('B22', '=COUNTA(B2:B12)') + ->setCellValue('B23', '=MAXA(B2:B12)') + ->setCellValue('B24', '=MINA(B2:B12)'); -$objPHPExcel->getActiveSheet()->setCellValue('B26', '=STDEV(B2:B12)'); -$objPHPExcel->getActiveSheet()->setCellValue('B27', '=STDEVA(B2:B12)'); -$objPHPExcel->getActiveSheet()->setCellValue('B28', '=STDEVP(B2:B12)'); -$objPHPExcel->getActiveSheet()->setCellValue('B29', '=STDEVPA(B2:B12)'); +$objPHPExcel->getActiveSheet()->setCellValue('B26', '=STDEV(B2:B12)') + ->setCellValue('B27', '=STDEVA(B2:B12)') + ->setCellValue('B28', '=STDEVP(B2:B12)') + ->setCellValue('B29', '=STDEVPA(B2:B12)'); -$objPHPExcel->getActiveSheet()->setCellValue('B31', '=DEVSQ(B2:B12)'); -$objPHPExcel->getActiveSheet()->setCellValue('B32', '=VAR(B2:B12)'); -$objPHPExcel->getActiveSheet()->setCellValue('B33', '=VARA(B2:B12)'); -$objPHPExcel->getActiveSheet()->setCellValue('B34', '=VARP(B2:B12)'); -$objPHPExcel->getActiveSheet()->setCellValue('B35', '=VARPA(B2:B12)'); +$objPHPExcel->getActiveSheet()->setCellValue('B31', '=DEVSQ(B2:B12)') + ->setCellValue('B32', '=VAR(B2:B12)') + ->setCellValue('B33', '=VARA(B2:B12)') + ->setCellValue('B34', '=VARP(B2:B12)') + ->setCellValue('B35', '=VARPA(B2:B12)'); -$objPHPExcel->getActiveSheet()->setCellValue('B37', '=DATE(2007, 12, 21)'); -$objPHPExcel->getActiveSheet()->setCellValue('B38', '=DATEDIF( DATE(2007, 12, 21), DATE(2007, 12, 22), "D" )'); -$objPHPExcel->getActiveSheet()->setCellValue('B39', '=DATEVALUE("01-Feb-2006 10:06 AM")'); -$objPHPExcel->getActiveSheet()->setCellValue('B40', '=DAY( DATE(2006, 1, 2) )'); -$objPHPExcel->getActiveSheet()->setCellValue('B41', '=DAYS360( DATE(2002, 2, 3), DATE(2005, 5, 31) )'); +$objPHPExcel->getActiveSheet()->setCellValue('B37', '=DATE(2007, 12, 21)') + ->setCellValue('B38', '=DATEDIF( DATE(2007, 12, 21), DATE(2007, 12, 22), "D" )') + ->setCellValue('B39', '=DATEVALUE("01-Feb-2006 10:06 AM")') + ->setCellValue('B40', '=DAY( DATE(2006, 1, 2) )') + ->setCellValue('B41', '=DAYS360( DATE(2002, 2, 3), DATE(2005, 5, 31) )'); -$objPHPExcel->getActiveSheet()->setCellValue('C1', 'Range 2'); -$objPHPExcel->getActiveSheet()->setCellValue('C2', 1); -$objPHPExcel->getActiveSheet()->setCellValue('C3', 2); -$objPHPExcel->getActiveSheet()->setCellValue('C4', 2); -$objPHPExcel->getActiveSheet()->setCellValue('C5', 3); -$objPHPExcel->getActiveSheet()->setCellValue('C6', 3); -$objPHPExcel->getActiveSheet()->setCellValue('C7', 3); -$objPHPExcel->getActiveSheet()->setCellValue('C8', '0'); -$objPHPExcel->getActiveSheet()->setCellValue('C9', 4); -$objPHPExcel->getActiveSheet()->setCellValue('C10', 4); -$objPHPExcel->getActiveSheet()->setCellValue('C11', 4); -$objPHPExcel->getActiveSheet()->setCellValue('C12', 4); +$objPHPExcel->getActiveSheet()->setCellValue('C1', 'Range 2') + ->setCellValue('C2', 1) + ->setCellValue('C3', 2) + ->setCellValue('C4', 2) + ->setCellValue('C5', 3) + ->setCellValue('C6', 3) + ->setCellValue('C7', 3) + ->setCellValue('C8', '0') + ->setCellValue('C9', 4) + ->setCellValue('C10', 4) + ->setCellValue('C11', 4) + ->setCellValue('C12', 4); -$objPHPExcel->getActiveSheet()->setCellValue('C14', '=COUNT(C2:C12)'); -$objPHPExcel->getActiveSheet()->setCellValue('C15', '=SUM(C2:C12)'); -$objPHPExcel->getActiveSheet()->setCellValue('C16', '=MAX(C2:C12)'); -$objPHPExcel->getActiveSheet()->setCellValue('C17', '=MIN(C2:C12)'); -$objPHPExcel->getActiveSheet()->setCellValue('C18', '=AVERAGE(C2:C12)'); -$objPHPExcel->getActiveSheet()->setCellValue('C19', '=MEDIAN(C2:C12)'); -$objPHPExcel->getActiveSheet()->setCellValue('C20', '=MODE(C2:C12)'); +$objPHPExcel->getActiveSheet()->setCellValue('C14', '=COUNT(C2:C12)') + ->setCellValue('C15', '=SUM(C2:C12)') + ->setCellValue('C16', '=MAX(C2:C12)') + ->setCellValue('C17', '=MIN(C2:C12)') + ->setCellValue('C18', '=AVERAGE(C2:C12)') + ->setCellValue('C19', '=MEDIAN(C2:C12)') + ->setCellValue('C20', '=MODE(C2:C12)'); -$objPHPExcel->getActiveSheet()->setCellValue('C22', '=COUNTA(C2:C12)'); -$objPHPExcel->getActiveSheet()->setCellValue('C23', '=MAXA(C2:C12)'); -$objPHPExcel->getActiveSheet()->setCellValue('C24', '=MINA(C2:C12)'); +$objPHPExcel->getActiveSheet()->setCellValue('C22', '=COUNTA(C2:C12)') + ->setCellValue('C23', '=MAXA(C2:C12)') + ->setCellValue('C24', '=MINA(C2:C12)'); -$objPHPExcel->getActiveSheet()->setCellValue('C26', '=STDEV(C2:C12)'); -$objPHPExcel->getActiveSheet()->setCellValue('C27', '=STDEVA(C2:C12)'); -$objPHPExcel->getActiveSheet()->setCellValue('C28', '=STDEVP(C2:C12)'); -$objPHPExcel->getActiveSheet()->setCellValue('C29', '=STDEVPA(C2:C12)'); +$objPHPExcel->getActiveSheet()->setCellValue('C26', '=STDEV(C2:C12)') + ->setCellValue('C27', '=STDEVA(C2:C12)') + ->setCellValue('C28', '=STDEVP(C2:C12)') + ->setCellValue('C29', '=STDEVPA(C2:C12)'); -$objPHPExcel->getActiveSheet()->setCellValue('C31', '=DEVSQ(C2:C12)'); -$objPHPExcel->getActiveSheet()->setCellValue('C32', '=VAR(C2:C12)'); -$objPHPExcel->getActiveSheet()->setCellValue('C33', '=VARA(C2:C12)'); -$objPHPExcel->getActiveSheet()->setCellValue('C34', '=VARP(C2:C12)'); -$objPHPExcel->getActiveSheet()->setCellValue('C35', '=VARPA(C2:C12)'); +$objPHPExcel->getActiveSheet()->setCellValue('C31', '=DEVSQ(C2:C12)') + ->setCellValue('C32', '=VAR(C2:C12)') + ->setCellValue('C33', '=VARA(C2:C12)') + ->setCellValue('C34', '=VARP(C2:C12)') + ->setCellValue('C35', '=VARPA(C2:C12)'); -$objPHPExcel->getActiveSheet()->setCellValue('D1', 'Range 3'); -$objPHPExcel->getActiveSheet()->setCellValue('D2', 2); -$objPHPExcel->getActiveSheet()->setCellValue('D3', 3); -$objPHPExcel->getActiveSheet()->setCellValue('D4', 4); +$objPHPExcel->getActiveSheet()->setCellValue('D1', 'Range 3') + ->setCellValue('D2', 2) + ->setCellValue('D3', 3) + ->setCellValue('D4', 4); $objPHPExcel->getActiveSheet()->setCellValue('D14', '=((D2 * D3) + D4) & " should be 10"'); -$objPHPExcel->getActiveSheet()->setCellValue('E12', 'Other functions'); -$objPHPExcel->getActiveSheet()->setCellValue('E14', '=PI()'); -$objPHPExcel->getActiveSheet()->setCellValue('E15', '=RAND()'); -$objPHPExcel->getActiveSheet()->setCellValue('E16', '=RANDBETWEEN(5, 10)'); +$objPHPExcel->getActiveSheet()->setCellValue('E12', 'Other functions') + ->setCellValue('E14', '=PI()') + ->setCellValue('E15', '=RAND()') + ->setCellValue('E16', '=RANDBETWEEN(5, 10)'); -$objPHPExcel->getActiveSheet()->setCellValue('E17', 'Count of both ranges:'); -$objPHPExcel->getActiveSheet()->setCellValue('F17', '=COUNT(B2:C12)'); +$objPHPExcel->getActiveSheet()->setCellValue('E17', 'Count of both ranges:') + ->setCellValue('F17', '=COUNT(B2:C12)'); -$objPHPExcel->getActiveSheet()->setCellValue('E18', 'Total of both ranges:'); -$objPHPExcel->getActiveSheet()->setCellValue('F18', '=SUM(B2:C12)'); +$objPHPExcel->getActiveSheet()->setCellValue('E18', 'Total of both ranges:') + ->setCellValue('F18', '=SUM(B2:C12)'); -$objPHPExcel->getActiveSheet()->setCellValue('E19', 'Maximum of both ranges:'); -$objPHPExcel->getActiveSheet()->setCellValue('F19', '=MAX(B2:C12)'); +$objPHPExcel->getActiveSheet()->setCellValue('E19', 'Maximum of both ranges:') + ->setCellValue('F19', '=MAX(B2:C12)'); -$objPHPExcel->getActiveSheet()->setCellValue('E20', 'Minimum of both ranges:'); -$objPHPExcel->getActiveSheet()->setCellValue('F20', '=MIN(B2:C12)'); +$objPHPExcel->getActiveSheet()->setCellValue('E20', 'Minimum of both ranges:') + ->setCellValue('F20', '=MIN(B2:C12)'); -$objPHPExcel->getActiveSheet()->setCellValue('E21', 'Average of both ranges:'); -$objPHPExcel->getActiveSheet()->setCellValue('F21', '=AVERAGE(B2:C12)'); +$objPHPExcel->getActiveSheet()->setCellValue('E21', 'Average of both ranges:') + ->setCellValue('F21', '=AVERAGE(B2:C12)'); -$objPHPExcel->getActiveSheet()->setCellValue('E22', 'Median of both ranges:'); -$objPHPExcel->getActiveSheet()->setCellValue('F22', '=MEDIAN(B2:C12)'); +$objPHPExcel->getActiveSheet()->setCellValue('E22', 'Median of both ranges:') + ->setCellValue('F22', '=MEDIAN(B2:C12)'); -$objPHPExcel->getActiveSheet()->setCellValue('E23', 'Mode of both ranges:'); -$objPHPExcel->getActiveSheet()->setCellValue('F23', '=MODE(B2:C12)'); +$objPHPExcel->getActiveSheet()->setCellValue('E23', 'Mode of both ranges:') + ->setCellValue('F23', '=MODE(B2:C12)'); // Calculated data -echo date('H:i:s') , " Calculated data" , PHP_EOL; +echo date('H:i:s') , " Calculated data" , EOL; for ($col = 'B'; $col != 'G'; ++$col) { for($row = 14; $row <= 41; ++$row) { if ((!is_null($formula = $objPHPExcel->getActiveSheet()->getCell($col.$row)->getValue())) && ($formula[0] == '=')) { echo 'Value of ' , $col , $row , ' [' , $formula , ']: ' , - $objPHPExcel->getActiveSheet()->getCell($col.$row)->getCalculatedValue() . PHP_EOL; + $objPHPExcel->getActiveSheet()->getCell($col.$row)->getCalculatedValue() . EOL; } } } // Save Excel 2007 file -echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL; +echo date('H:i:s') , " Write to Excel2007 format" , EOL; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); -echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', __FILE__) , PHP_EOL; +echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; // Echo memory peak usage -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL; +echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; // Echo done -echo date('H:i:s') , " Done" , PHP_EOL; +echo date('H:i:s') , " Done writing file" , EOL; +echo 'File has been created in ' , getcwd() , EOL; diff --git a/Tests/14excel5.php b/Tests/14excel5.php index 82e61de..bded748 100644 --- a/Tests/14excel5.php +++ b/Tests/14excel5.php @@ -27,6 +27,11 @@ /** Error reporting */ error_reporting(E_ALL); +ini_set('display_errors', TRUE); +ini_set('display_startup_errors', TRUE); +date_default_timezone_set('Europe/London'); + +define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '
'); date_default_timezone_set('Europe/London'); @@ -36,14 +41,15 @@ include "05featuredemo.inc.php"; require_once '../Classes/PHPExcel/IOFactory.php'; -echo date('H:i:s') , " Write to Excel5 format" , PHP_EOL; +echo date('H:i:s') , " Write to Excel5 format" , EOL; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save(str_replace('.php', '.xls', __FILE__)); -echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', __FILE__) , PHP_EOL; +echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; // Echo memory peak usage -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL; +echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; // Echo done -echo date('H:i:s') , " Done writing files" , PHP_EOL; +echo date('H:i:s') , " Done writing file" , EOL; +echo 'File has been created in ' , getcwd() , EOL; diff --git a/Tests/15datavalidation-xls.php b/Tests/15datavalidation-xls.php index 87ad54d..2f795ca 100644 --- a/Tests/15datavalidation-xls.php +++ b/Tests/15datavalidation-xls.php @@ -27,6 +27,11 @@ /** Error reporting */ error_reporting(E_ALL); +ini_set('display_errors', TRUE); +ini_set('display_startup_errors', TRUE); +date_default_timezone_set('Europe/London'); + +define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '
'); date_default_timezone_set('Europe/London'); @@ -35,12 +40,12 @@ require_once '../Classes/PHPExcel.php'; // Create new PHPExcel object -echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL; +echo date('H:i:s') , " Create new PHPExcel object" , EOL; $objPHPExcel = new PHPExcel(); // Set document properties -echo date('H:i:s') , " Set document properties" , PHP_EOL; +echo date('H:i:s') , " Set document properties" , EOL; $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") ->setLastModifiedBy("Maarten Balliauw") ->setTitle("Office 2007 XLSX Test Document") @@ -51,17 +56,17 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") // Create a first sheet -echo date('H:i:s') , " Add data" , PHP_EOL; +echo date('H:i:s') , " Add data" , EOL; $objPHPExcel->setActiveSheetIndex(0); -$objPHPExcel->getActiveSheet()->setCellValue('A1', "Cell B3 and B5 contain data validation..."); -$objPHPExcel->getActiveSheet()->setCellValue('A3', "Number:"); -$objPHPExcel->getActiveSheet()->setCellValue('B3', "10"); -$objPHPExcel->getActiveSheet()->setCellValue('A5', "List:"); -$objPHPExcel->getActiveSheet()->setCellValue('B5', "Item A"); +$objPHPExcel->getActiveSheet()->setCellValue('A1', "Cell B3 and B5 contain data validation...") + ->setCellValue('A3', "Number:") + ->setCellValue('B3', "10") + ->setCellValue('A5', "List:") + ->setCellValue('B5', "Item A"); // Set data validation -echo date('H:i:s') , " Set data validation" , PHP_EOL; +echo date('H:i:s') , " Set data validation" , EOL; $objValidation = $objPHPExcel->getActiveSheet()->getCell('B3')->getDataValidation(); $objValidation->setType( PHPExcel_Cell_DataValidation::TYPE_WHOLE ); $objValidation->setErrorStyle( PHPExcel_Cell_DataValidation::STYLE_STOP ); @@ -94,14 +99,15 @@ $objPHPExcel->setActiveSheetIndex(0); // Save Excel 2007 file -echo date('H:i:s') , " Write to Excel5 format" , PHP_EOL; +echo date('H:i:s') , " Write to Excel5 format" , EOL; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save(str_replace('.php', '.xls', __FILE__)); -echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', __FILE__) , PHP_EOL; +echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; // Echo memory peak usage -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL; +echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; // Echo done -echo date('H:i:s') , " Done writing file" , PHP_EOL; +echo date('H:i:s') , " Done writing file" , EOL; +echo 'File has been created in ' , getcwd() , EOL; diff --git a/Tests/15datavalidation.php b/Tests/15datavalidation.php index 6f8809b..c5221d6 100644 --- a/Tests/15datavalidation.php +++ b/Tests/15datavalidation.php @@ -27,6 +27,11 @@ /** Error reporting */ error_reporting(E_ALL); +ini_set('display_errors', TRUE); +ini_set('display_startup_errors', TRUE); +date_default_timezone_set('Europe/London'); + +define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '
'); date_default_timezone_set('Europe/London'); @@ -35,12 +40,12 @@ require_once '../Classes/PHPExcel.php'; // Create new PHPExcel object -echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL; +echo date('H:i:s') , " Create new PHPExcel object" , EOL; $objPHPExcel = new PHPExcel(); // Set document properties -echo date('H:i:s') , " Set document properties" , PHP_EOL; +echo date('H:i:s') , " Set document properties" , EOL; $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") ->setLastModifiedBy("Maarten Balliauw") ->setTitle("Office 2007 XLSX Test Document") @@ -51,17 +56,17 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") // Create a first sheet -echo date('H:i:s') , " Add data" , PHP_EOL; +echo date('H:i:s') , " Add data" , EOL; $objPHPExcel->setActiveSheetIndex(0); -$objPHPExcel->getActiveSheet()->setCellValue('A1', "Cell B3 and B5 contain data validation..."); -$objPHPExcel->getActiveSheet()->setCellValue('A3', "Number:"); -$objPHPExcel->getActiveSheet()->setCellValue('B3', "10"); -$objPHPExcel->getActiveSheet()->setCellValue('A5', "List:"); -$objPHPExcel->getActiveSheet()->setCellValue('B5', "Item A"); +$objPHPExcel->getActiveSheet()->setCellValue('A1', "Cell B3 and B5 contain data validation...") + ->setCellValue('A3', "Number:") + ->setCellValue('B3', "10") + ->setCellValue('A5', "List:") + ->setCellValue('B5', "Item A"); // Set data validation -echo date('H:i:s') , " Set data validation" , PHP_EOL; +echo date('H:i:s') , " Set data validation" , EOL; $objValidation = $objPHPExcel->getActiveSheet()->getCell('B3')->getDataValidation(); $objValidation->setType( PHPExcel_Cell_DataValidation::TYPE_WHOLE ); $objValidation->setErrorStyle( PHPExcel_Cell_DataValidation::STYLE_STOP ); @@ -94,14 +99,15 @@ $objPHPExcel->setActiveSheetIndex(0); // Save Excel 2007 file -echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL; +echo date('H:i:s') , " Write to Excel2007 format" , EOL; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); -echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', __FILE__) , PHP_EOL; +echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; // Echo memory peak usage -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL; +echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; // Echo done -echo date('H:i:s') , " Done writing file" , PHP_EOL; +echo date('H:i:s') , " Done writing file" , EOL; +echo 'File has been created in ' , getcwd() , EOL; diff --git a/Tests/16csv.php b/Tests/16csv.php index f205708..db377c6 100644 --- a/Tests/16csv.php +++ b/Tests/16csv.php @@ -27,6 +27,11 @@ /** Error reporting */ error_reporting(E_ALL); +ini_set('display_errors', TRUE); +ini_set('display_startup_errors', TRUE); +date_default_timezone_set('Europe/London'); + +define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '
'); date_default_timezone_set('Europe/London'); @@ -36,31 +41,32 @@ include "05featuredemo.inc.php"; require_once '../Classes/PHPExcel/IOFactory.php'; -echo date('H:i:s') , " Write to CSV format" , PHP_EOL; +echo date('H:i:s') , " Write to CSV format" , EOL; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV')->setDelimiter(',') ->setEnclosure('"') ->setLineEnding("\r\n") ->setSheetIndex(0) ->save(str_replace('.php', '.csv', __FILE__)); -echo date('H:i:s') , " File written to " , str_replace('.php', '.csv', __FILE__) , PHP_EOL; +echo date('H:i:s') , " File written to " , str_replace('.php', '.csv', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; -echo date('H:i:s') , " Read from CSV format" , PHP_EOL; +echo date('H:i:s') , " Read from CSV format" , EOL; $objReader = PHPExcel_IOFactory::createReader('CSV')->setDelimiter(',') ->setEnclosure('"') ->setLineEnding("\r\n") ->setSheetIndex(0); $objPHPExcelFromCSV = $objReader->load(str_replace('.php', '.csv', __FILE__)); -echo date('H:i:s') , " File read from " , str_replace('.php', '.csv', __FILE__) , PHP_EOL; +echo date('H:i:s') , " File read from " , str_replace('.php', '.csv', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; -echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL; +echo date('H:i:s') , " Write to Excel2007 format" , EOL; $objWriter2007 = PHPExcel_IOFactory::createWriter($objPHPExcelFromCSV, 'Excel2007'); $objWriter2007->save(str_replace('.php', '.xlsx', __FILE__)); -echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', __FILE__) , PHP_EOL; +echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; // Echo memory peak usage -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL; +echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; // Echo done -echo date('H:i:s') , " Done writing files" , PHP_EOL; +echo date('H:i:s') , " Done writing files" , EOL; +echo 'Files have been created in ' , getcwd() , EOL; diff --git a/Tests/17html.php b/Tests/17html.php index 281b86a..5bfcab3 100644 --- a/Tests/17html.php +++ b/Tests/17html.php @@ -27,6 +27,11 @@ /** Error reporting */ error_reporting(E_ALL); +ini_set('display_errors', TRUE); +ini_set('display_startup_errors', TRUE); +date_default_timezone_set('Europe/London'); + +define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '
'); date_default_timezone_set('Europe/London'); @@ -36,16 +41,17 @@ include "05featuredemo.inc.php"; require_once '../Classes/PHPExcel/IOFactory.php'; -echo date('H:i:s') , " Write to HTML format" , PHP_EOL; +echo date('H:i:s') , " Write to HTML format" , EOL; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML'); $objWriter->setSheetIndex(0); //$objWriter->setImagesRoot('http://www.example.com'); $objWriter->save(str_replace('.php', '.htm', __FILE__)); -echo date('H:i:s') , " File written to " , str_replace('.php', '.htm', __FILE__) , PHP_EOL; +echo date('H:i:s') , " File written to " , str_replace('.php', '.htm', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; // Echo memory peak usage -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL; +echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; // Echo done -echo date('H:i:s') , " Done writing files" , PHP_EOL; +echo date('H:i:s') , " Done writing file" , EOL; +echo 'File has been created in ' , getcwd() , EOL;