visualizer
/
vendor
/
phpoffice
/
phpexcel
/
Documentation
/
Examples
/
Reader
/
exampleReader13.php
exampleReader13.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.1.1, at vendor/phpoffice/phpexcel/Documentation/Examples/Reader/exampleReader13.php
| 1 | <?php |
| 2 | |
| 3 | error_reporting(E_ALL); |
| 4 | set_time_limit(0); |
| 5 | |
| 6 | date_default_timezone_set('Europe/London'); |
| 7 | |
| 8 | ?> |
| 9 | <html> |
| 10 | <head> |
| 11 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| 12 | |
| 13 | <title>PHPExcel Reader Example #13</title> |
| 14 | |
| 15 | </head> |
| 16 | <body> |
| 17 | |
| 18 | <h1>PHPExcel Reader Example #13</h1> |
| 19 | <h2>Simple File Reader for Multiple CSV Files</h2> |
| 20 | <?php |
| 21 | |
| 22 | /** Include path **/ |
| 23 | set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/'); |
| 24 | |
| 25 | /** PHPExcel_IOFactory */ |
| 26 | include 'PHPExcel/IOFactory.php'; |
| 27 | |
| 28 | |
| 29 | $inputFileType = 'CSV'; |
| 30 | $inputFileNames = array('./sampleData/example1.csv','./sampleData/example2.csv'); |
| 31 | |
| 32 | $objReader = PHPExcel_IOFactory::createReader($inputFileType); |
| 33 | $inputFileName = array_shift($inputFileNames); |
| 34 | echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' into WorkSheet #1 using IOFactory with a defined reader type of ',$inputFileType,'<br />'; |
| 35 | $objPHPExcel = $objReader->load($inputFileName); |
| 36 | $objPHPExcel->getActiveSheet()->setTitle(pathinfo($inputFileName,PATHINFO_BASENAME)); |
| 37 | foreach($inputFileNames as $sheet => $inputFileName) { |
| 38 | echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' into WorkSheet #',($sheet+2),' using IOFactory with a defined reader type of ',$inputFileType,'<br />'; |
| 39 | $objReader->setSheetIndex($sheet+1); |
| 40 | $objReader->loadIntoExisting($inputFileName,$objPHPExcel); |
| 41 | $objPHPExcel->getActiveSheet()->setTitle(pathinfo($inputFileName,PATHINFO_BASENAME)); |
| 42 | } |
| 43 | |
| 44 | |
| 45 | echo '<hr />'; |
| 46 | |
| 47 | echo $objPHPExcel->getSheetCount(),' worksheet',(($objPHPExcel->getSheetCount() == 1) ? '' : 's'),' loaded<br /><br />'; |
| 48 | $loadedSheetNames = $objPHPExcel->getSheetNames(); |
| 49 | foreach($loadedSheetNames as $sheetIndex => $loadedSheetName) { |
| 50 | echo '<b>Worksheet #',$sheetIndex,' -> ',$loadedSheetName,'</b><br />'; |
| 51 | $objPHPExcel->setActiveSheetIndexByName($loadedSheetName); |
| 52 | $sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); |
| 53 | var_dump($sheetData); |
| 54 | echo '<br /><br />'; |
| 55 | } |
| 56 | |
| 57 | |
| 58 | ?> |
| 59 | <body> |
| 60 | </html> |