@@ -21,47 +21,47 @@ |
||
21 | 21 | include 'PHPExcel/IOFactory.php'; |
22 | 22 | |
23 | 23 | |
24 | -PHPExcel_Cell::setValueBinder( new PHPExcel_Cell_AdvancedValueBinder() ); |
|
24 | +PHPExcel_Cell::setValueBinder(new PHPExcel_Cell_AdvancedValueBinder()); |
|
25 | 25 | |
26 | 26 | |
27 | 27 | $inputFileType = 'CSV'; |
28 | 28 | $inputFileName = './sampleData/example1.tsv'; |
29 | 29 | |
30 | 30 | $objReader = PHPExcel_IOFactory::createReader($inputFileType); |
31 | -echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' into WorkSheet #1 using IOFactory with a defined reader type of ',$inputFileType,'<br />'; |
|
31 | +echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' into WorkSheet #1 using IOFactory with a defined reader type of ', $inputFileType, '<br />'; |
|
32 | 32 | $objReader->setDelimiter("\t"); |
33 | 33 | $objPHPExcel = $objReader->load($inputFileName); |
34 | -$objPHPExcel->getActiveSheet()->setTitle(pathinfo($inputFileName,PATHINFO_BASENAME)); |
|
34 | +$objPHPExcel->getActiveSheet()->setTitle(pathinfo($inputFileName, PATHINFO_BASENAME)); |
|
35 | 35 | |
36 | 36 | |
37 | 37 | echo '<hr />'; |
38 | 38 | |
39 | -echo $objPHPExcel->getSheetCount(),' worksheet',(($objPHPExcel->getSheetCount() == 1) ? '' : 's'),' loaded<br /><br />'; |
|
39 | +echo $objPHPExcel->getSheetCount(), ' worksheet', (($objPHPExcel->getSheetCount() == 1) ? '' : 's'), ' loaded<br /><br />'; |
|
40 | 40 | $loadedSheetNames = $objPHPExcel->getSheetNames(); |
41 | -foreach($loadedSheetNames as $sheetIndex => $loadedSheetName) { |
|
42 | - echo '<b>Worksheet #',$sheetIndex,' -> ',$loadedSheetName,' (Formatted)</b><br />'; |
|
41 | +foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) { |
|
42 | + echo '<b>Worksheet #', $sheetIndex, ' -> ', $loadedSheetName, ' (Formatted)</b><br />'; |
|
43 | 43 | $objPHPExcel->setActiveSheetIndexByName($loadedSheetName); |
44 | - $sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); |
|
44 | + $sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true); |
|
45 | 45 | var_dump($sheetData); |
46 | 46 | echo '<br />'; |
47 | 47 | } |
48 | 48 | |
49 | 49 | echo '<hr />'; |
50 | 50 | |
51 | -foreach($loadedSheetNames as $sheetIndex => $loadedSheetName) { |
|
52 | - echo '<b>Worksheet #',$sheetIndex,' -> ',$loadedSheetName,' (Unformatted)</b><br />'; |
|
51 | +foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) { |
|
52 | + echo '<b>Worksheet #', $sheetIndex, ' -> ', $loadedSheetName, ' (Unformatted)</b><br />'; |
|
53 | 53 | $objPHPExcel->setActiveSheetIndexByName($loadedSheetName); |
54 | - $sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,false,true); |
|
54 | + $sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, false, true); |
|
55 | 55 | var_dump($sheetData); |
56 | 56 | echo '<br />'; |
57 | 57 | } |
58 | 58 | |
59 | 59 | echo '<hr />'; |
60 | 60 | |
61 | -foreach($loadedSheetNames as $sheetIndex => $loadedSheetName) { |
|
62 | - echo '<b>Worksheet #',$sheetIndex,' -> ',$loadedSheetName,' (Raw)</b><br />'; |
|
61 | +foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) { |
|
62 | + echo '<b>Worksheet #', $sheetIndex, ' -> ', $loadedSheetName, ' (Raw)</b><br />'; |
|
63 | 63 | $objPHPExcel->setActiveSheetIndexByName($loadedSheetName); |
64 | - $sheetData = $objPHPExcel->getActiveSheet()->toArray(null,false,false,true); |
|
64 | + $sheetData = $objPHPExcel->getActiveSheet()->toArray(null, false, false, true); |
|
65 | 65 | var_dump($sheetData); |
66 | 66 | echo '<br />'; |
67 | 67 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | // $inputFileType = 'Gnumeric'; |
34 | 34 | $inputFileName = './sampleData/example1.xls'; |
35 | 35 | |
36 | -echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'<br />'; |
|
36 | +echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '<br />'; |
|
37 | 37 | $objReader = PHPExcel_IOFactory::createReader($inputFileType); |
38 | 38 | echo 'Loading all WorkSheets<br />'; |
39 | 39 | $objReader->setLoadAllSheets(); |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | |
43 | 43 | echo '<hr />'; |
44 | 44 | |
45 | -echo $objPHPExcel->getSheetCount(),' worksheet',(($objPHPExcel->getSheetCount() == 1) ? '' : 's'),' loaded<br /><br />'; |
|
45 | +echo $objPHPExcel->getSheetCount(), ' worksheet', (($objPHPExcel->getSheetCount() == 1) ? '' : 's'), ' loaded<br /><br />'; |
|
46 | 46 | $loadedSheetNames = $objPHPExcel->getSheetNames(); |
47 | -foreach($loadedSheetNames as $sheetIndex => $loadedSheetName) { |
|
48 | - echo $sheetIndex,' -> ',$loadedSheetName,'<br />'; |
|
47 | +foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) { |
|
48 | + echo $sheetIndex, ' -> ', $loadedSheetName, '<br />'; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | |
44 | 44 | /** We expect a list of the rows that we want to read to be passed into the constructor */ |
45 | 45 | public function __construct($startRow, $chunkSize) { |
46 | - $this->_startRow = $startRow; |
|
47 | - $this->_endRow = $startRow + $chunkSize; |
|
46 | + $this->_startRow = $startRow; |
|
47 | + $this->_endRow = $startRow + $chunkSize; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | public function readCell($column, $row, $worksheetName = '') { |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | } |
58 | 58 | |
59 | 59 | |
60 | -echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'<br />'; |
|
60 | +echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '<br />'; |
|
61 | 61 | /** Create a new Reader of the type defined in $inputFileType **/ |
62 | 62 | $objReader = PHPExcel_IOFactory::createReader($inputFileType); |
63 | 63 | |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | |
71 | 71 | /** Loop to read our worksheet in "chunk size" blocks **/ |
72 | 72 | for ($startRow = 2; $startRow <= 240; $startRow += $chunkSize) { |
73 | - echo 'Loading WorkSheet using configurable filter for headings row 1 and for rows ',$startRow,' to ',($startRow+$chunkSize-1),'<br />'; |
|
73 | + echo 'Loading WorkSheet using configurable filter for headings row 1 and for rows ', $startRow, ' to ', ($startRow + $chunkSize - 1), '<br />'; |
|
74 | 74 | /** Create a new Instance of our Read Filter, passing in the limits on which rows we want to read **/ |
75 | - $chunkFilter = new chunkReadFilter($startRow,$chunkSize); |
|
75 | + $chunkFilter = new chunkReadFilter($startRow, $chunkSize); |
|
76 | 76 | /** Tell the Reader that we want to use the new Read Filter that we've just Instantiated **/ |
77 | 77 | $objReader->setReadFilter($chunkFilter); |
78 | 78 | /** Load only the rows that match our filter from $inputFileName to a PHPExcel Object **/ |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | |
81 | 81 | // Do some processing here |
82 | 82 | |
83 | - $sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); |
|
83 | + $sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true); |
|
84 | 84 | var_dump($sheetData); |
85 | 85 | echo '<br /><br />'; |
86 | 86 | } |
@@ -27,17 +27,17 @@ |
||
27 | 27 | |
28 | 28 | |
29 | 29 | $inputFileName = './sampleData/example_1.xls'; |
30 | -echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory to identify the format<br />'; |
|
30 | +echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory to identify the format<br />'; |
|
31 | 31 | try { |
32 | 32 | $objPHPExcel = PHPExcel_IOFactory::load($inputFileName); |
33 | -} catch(\PHPExcel\Reader\Exception $e) { |
|
34 | - die('Error loading file "'.pathinfo($inputFileName,PATHINFO_BASENAME).'": '.$e->getMessage()); |
|
33 | +} catch (\PHPExcel\Reader\Exception $e) { |
|
34 | + die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage()); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
38 | 38 | echo '<hr />'; |
39 | 39 | |
40 | -$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); |
|
40 | +$sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true); |
|
41 | 41 | var_dump($sheetData); |
42 | 42 | |
43 | 43 |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | |
44 | 44 | /** Set the list of rows that we want to read */ |
45 | 45 | public function setRows($startRow, $chunkSize) { |
46 | - $this->_startRow = $startRow; |
|
47 | - $this->_endRow = $startRow + $chunkSize; |
|
46 | + $this->_startRow = $startRow; |
|
47 | + $this->_endRow = $startRow + $chunkSize; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | public function readCell($column, $row, $worksheetName = '') { |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | } |
58 | 58 | |
59 | 59 | |
60 | -echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'<br />'; |
|
60 | +echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '<br />'; |
|
61 | 61 | /** Create a new Reader of the type defined in $inputFileType **/ |
62 | 62 | $objReader = PHPExcel_IOFactory::createReader($inputFileType); |
63 | 63 | |
@@ -75,15 +75,15 @@ discard block |
||
75 | 75 | |
76 | 76 | /** Loop to read our worksheet in "chunk size" blocks **/ |
77 | 77 | for ($startRow = 2; $startRow <= 240; $startRow += $chunkSize) { |
78 | - echo 'Loading WorkSheet using configurable filter for headings row 1 and for rows ',$startRow,' to ',($startRow+$chunkSize-1),'<br />'; |
|
78 | + echo 'Loading WorkSheet using configurable filter for headings row 1 and for rows ', $startRow, ' to ', ($startRow + $chunkSize - 1), '<br />'; |
|
79 | 79 | /** Tell the Read Filter, the limits on which rows we want to read this iteration **/ |
80 | - $chunkFilter->setRows($startRow,$chunkSize); |
|
80 | + $chunkFilter->setRows($startRow, $chunkSize); |
|
81 | 81 | /** Load only the rows that match our filter from $inputFileName to a PHPExcel Object **/ |
82 | 82 | $objPHPExcel = $objReader->load($inputFileName); |
83 | 83 | |
84 | 84 | // Do some processing here |
85 | 85 | |
86 | - $sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); |
|
86 | + $sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true); |
|
87 | 87 | var_dump($sheetData); |
88 | 88 | echo '<br /><br />'; |
89 | 89 | } |
@@ -29,16 +29,16 @@ |
||
29 | 29 | $inputFileName = './sampleData/example1.xls'; |
30 | 30 | |
31 | 31 | $inputFileType = PHPExcel_IOFactory::identify($inputFileName); |
32 | -echo 'File ',pathinfo($inputFileName,PATHINFO_BASENAME),' has been identified as an ',$inputFileType,' file<br />'; |
|
32 | +echo 'File ', pathinfo($inputFileName, PATHINFO_BASENAME), ' has been identified as an ', $inputFileType, ' file<br />'; |
|
33 | 33 | |
34 | -echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory with the identified reader type<br />'; |
|
34 | +echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with the identified reader type<br />'; |
|
35 | 35 | $objReader = PHPExcel_IOFactory::createReader($inputFileType); |
36 | 36 | $objPHPExcel = $objReader->load($inputFileName); |
37 | 37 | |
38 | 38 | |
39 | 39 | echo '<hr />'; |
40 | 40 | |
41 | -$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); |
|
41 | +$sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true); |
|
42 | 42 | var_dump($sheetData); |
43 | 43 | |
44 | 44 |
@@ -34,19 +34,19 @@ |
||
34 | 34 | $inputFileName = './sampleData/example1.xls'; |
35 | 35 | $sheetname = 'Data Sheet #2'; |
36 | 36 | |
37 | -echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'<br />'; |
|
37 | +echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '<br />'; |
|
38 | 38 | $objReader = PHPExcel_IOFactory::createReader($inputFileType); |
39 | -echo 'Loading Sheet "',$sheetname,'" only<br />'; |
|
39 | +echo 'Loading Sheet "', $sheetname, '" only<br />'; |
|
40 | 40 | $objReader->setLoadSheetsOnly($sheetname); |
41 | 41 | $objPHPExcel = $objReader->load($inputFileName); |
42 | 42 | |
43 | 43 | |
44 | 44 | echo '<hr />'; |
45 | 45 | |
46 | -echo $objPHPExcel->getSheetCount(),' worksheet',(($objPHPExcel->getSheetCount() == 1) ? '' : 's'),' loaded<br /><br />'; |
|
46 | +echo $objPHPExcel->getSheetCount(), ' worksheet', (($objPHPExcel->getSheetCount() == 1) ? '' : 's'), ' loaded<br /><br />'; |
|
47 | 47 | $loadedSheetNames = $objPHPExcel->getSheetNames(); |
48 | -foreach($loadedSheetNames as $sheetIndex => $loadedSheetName) { |
|
49 | - echo $sheetIndex,' -> ',$loadedSheetName,'<br />'; |
|
48 | +foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) { |
|
49 | + echo $sheetIndex, ' -> ', $loadedSheetName, '<br />'; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 |
@@ -45,13 +45,13 @@ discard block |
||
45 | 45 | |
46 | 46 | public function __construct($startRow, $endRow, $columns) { |
47 | 47 | $this->_startRow = $startRow; |
48 | - $this->_endRow = $endRow; |
|
48 | + $this->_endRow = $endRow; |
|
49 | 49 | $this->_columns = $columns; |
50 | 50 | } |
51 | 51 | |
52 | 52 | public function readCell($column, $row, $worksheetName = '') { |
53 | 53 | if ($row >= $this->_startRow && $row <= $this->_endRow) { |
54 | - if (in_array($column,$this->_columns)) { |
|
54 | + if (in_array($column, $this->_columns)) { |
|
55 | 55 | return true; |
56 | 56 | } |
57 | 57 | } |
@@ -59,12 +59,12 @@ discard block |
||
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
62 | -$filterSubset = new MyReadFilter(9,15,range('G','K')); |
|
62 | +$filterSubset = new MyReadFilter(9, 15, range('G', 'K')); |
|
63 | 63 | |
64 | 64 | |
65 | -echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'<br />'; |
|
65 | +echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '<br />'; |
|
66 | 66 | $objReader = PHPExcel_IOFactory::createReader($inputFileType); |
67 | -echo 'Loading Sheet "',$sheetname,'" only<br />'; |
|
67 | +echo 'Loading Sheet "', $sheetname, '" only<br />'; |
|
68 | 68 | $objReader->setLoadSheetsOnly($sheetname); |
69 | 69 | echo 'Loading Sheet using configurable filter<br />'; |
70 | 70 | $objReader->setReadFilter($filterSubset); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | echo '<hr />'; |
75 | 75 | |
76 | -$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); |
|
76 | +$sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true); |
|
77 | 77 | var_dump($sheetData); |
78 | 78 | |
79 | 79 |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | // $inputFileType = 'Gnumeric'; |
34 | 34 | $inputFileName = './sampleData/example1.xls'; |
35 | 35 | |
36 | -echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'<br />'; |
|
36 | +echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '<br />'; |
|
37 | 37 | $objReader = PHPExcel_IOFactory::createReader($inputFileType); |
38 | 38 | |
39 | 39 | |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | echo 'Read the list of Worksheets in the WorkBook<br />'; |
42 | 42 | $worksheetNames = $objReader->listWorksheetNames($inputFileName); |
43 | 43 | |
44 | -echo 'There are ',count($worksheetNames),' worksheet',((count($worksheetNames) == 1) ? '' : 's'),' in the workbook<br /><br />'; |
|
45 | -foreach($worksheetNames as $worksheetName) { |
|
46 | - echo $worksheetName,'<br />'; |
|
44 | +echo 'There are ', count($worksheetNames), ' worksheet', ((count($worksheetNames) == 1) ? '' : 's'), ' in the workbook<br /><br />'; |
|
45 | +foreach ($worksheetNames as $worksheetName) { |
|
46 | + echo $worksheetName, '<br />'; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 |