@@ -46,7 +46,7 @@ |
||
46 | 46 | /** Use the PHPExcel object's getSheetNames() method to get an array listing the names/titles of the WorkSheets in the WorkBook */ |
47 | 47 | $sheetNames = $objPHPExcel->getSheetNames(); |
48 | 48 | foreach($sheetNames as $sheetIndex => $sheetName) { |
49 | - echo 'WorkSheet #',$sheetIndex,' is named "',$sheetName,'"<br />'; |
|
49 | + echo 'WorkSheet #',$sheetIndex,' is named "',$sheetName,'"<br />'; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 |
@@ -40,13 +40,13 @@ |
||
40 | 40 | echo 'Reading the number of Worksheets in the WorkBook<br />'; |
41 | 41 | /** Use the PHPExcel object's getSheetCount() method to get a count of the number of WorkSheets in the WorkBook */ |
42 | 42 | $sheetCount = $objPHPExcel->getSheetCount(); |
43 | -echo 'There ',(($sheetCount == 1) ? 'is' : 'are'),' ',$sheetCount,' WorkSheet',(($sheetCount == 1) ? '' : 's'),' in the WorkBook<br /><br />'; |
|
43 | +echo 'There ', (($sheetCount == 1) ? 'is' : 'are'), ' ', $sheetCount, ' WorkSheet', (($sheetCount == 1) ? '' : 's'), ' in the WorkBook<br /><br />'; |
|
44 | 44 | |
45 | 45 | echo 'Reading the names of Worksheets in the WorkBook<br />'; |
46 | 46 | /** Use the PHPExcel object's getSheetNames() method to get an array listing the names/titles of the WorkSheets in the WorkBook */ |
47 | 47 | $sheetNames = $objPHPExcel->getSheetNames(); |
48 | -foreach($sheetNames as $sheetIndex => $sheetName) { |
|
49 | - echo 'WorkSheet #',$sheetIndex,' is named "',$sheetName,'"<br />'; |
|
48 | +foreach ($sheetNames as $sheetIndex => $sheetName) { |
|
49 | + echo 'WorkSheet #', $sheetIndex, ' is named "', $sheetName, '"<br />'; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 |
@@ -42,7 +42,7 @@ |
||
42 | 42 | |
43 | 43 | echo '<b>Custom Property names: </b><br />'; |
44 | 44 | foreach($customPropertyList as $customPropertyName) { |
45 | - echo $customPropertyName,'<br />'; |
|
45 | + echo $customPropertyName,'<br />'; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 |
@@ -41,8 +41,8 @@ |
||
41 | 41 | $customPropertyList = $objPHPExcel->getProperties()->getCustomProperties(); |
42 | 42 | |
43 | 43 | echo '<b>Custom Property names: </b><br />'; |
44 | -foreach($customPropertyList as $customPropertyName) { |
|
45 | - echo $customPropertyName,'<br />'; |
|
44 | +foreach ($customPropertyList as $customPropertyName) { |
|
45 | + echo $customPropertyName, '<br />'; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 |
@@ -43,34 +43,34 @@ |
||
43 | 43 | echo '<b>Custom Properties: </b><br />'; |
44 | 44 | /** Loop through the list of custom properties **/ |
45 | 45 | foreach($customPropertyList as $customPropertyName) { |
46 | - echo '<b>',$customPropertyName,': </b>'; |
|
47 | - /** Retrieve the property value **/ |
|
48 | - $propertyValue = $objPHPExcel->getProperties()->getCustomPropertyValue($customPropertyName); |
|
49 | - /** Retrieve the property type **/ |
|
50 | - $propertyType = $objPHPExcel->getProperties()->getCustomPropertyType($customPropertyName); |
|
51 | - |
|
52 | - /** Manipulate properties as appropriate for display purposes **/ |
|
53 | - switch($propertyType) { |
|
54 | - case 'i' : // integer |
|
55 | - $propertyType = 'integer number'; |
|
56 | - break; |
|
57 | - case 'f' : // float |
|
58 | - $propertyType = 'floating point number'; |
|
59 | - break; |
|
60 | - case 's' : // string |
|
61 | - $propertyType = 'string'; |
|
62 | - break; |
|
63 | - case 'd' : // date |
|
64 | - $propertyValue = date('l, d<\s\up>S</\s\up> F Y g:i A',$propertyValue); |
|
65 | - $propertyType = 'date'; |
|
66 | - break; |
|
67 | - case 'b' : // boolean |
|
68 | - $propertyValue = ($propertyValue) ? 'TRUE' : 'FALSE'; |
|
69 | - $propertyType = 'boolean'; |
|
70 | - break; |
|
71 | - } |
|
72 | - |
|
73 | - echo $propertyValue,' (',$propertyType,')<br />'; |
|
46 | + echo '<b>',$customPropertyName,': </b>'; |
|
47 | + /** Retrieve the property value **/ |
|
48 | + $propertyValue = $objPHPExcel->getProperties()->getCustomPropertyValue($customPropertyName); |
|
49 | + /** Retrieve the property type **/ |
|
50 | + $propertyType = $objPHPExcel->getProperties()->getCustomPropertyType($customPropertyName); |
|
51 | + |
|
52 | + /** Manipulate properties as appropriate for display purposes **/ |
|
53 | + switch($propertyType) { |
|
54 | + case 'i' : // integer |
|
55 | + $propertyType = 'integer number'; |
|
56 | + break; |
|
57 | + case 'f' : // float |
|
58 | + $propertyType = 'floating point number'; |
|
59 | + break; |
|
60 | + case 's' : // string |
|
61 | + $propertyType = 'string'; |
|
62 | + break; |
|
63 | + case 'd' : // date |
|
64 | + $propertyValue = date('l, d<\s\up>S</\s\up> F Y g:i A',$propertyValue); |
|
65 | + $propertyType = 'date'; |
|
66 | + break; |
|
67 | + case 'b' : // boolean |
|
68 | + $propertyValue = ($propertyValue) ? 'TRUE' : 'FALSE'; |
|
69 | + $propertyType = 'boolean'; |
|
70 | + break; |
|
71 | + } |
|
72 | + |
|
73 | + echo $propertyValue,' (',$propertyType,')<br />'; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 |
@@ -42,15 +42,15 @@ discard block |
||
42 | 42 | |
43 | 43 | echo '<b>Custom Properties: </b><br />'; |
44 | 44 | /** Loop through the list of custom properties **/ |
45 | -foreach($customPropertyList as $customPropertyName) { |
|
46 | - echo '<b>',$customPropertyName,': </b>'; |
|
45 | +foreach ($customPropertyList as $customPropertyName) { |
|
46 | + echo '<b>', $customPropertyName, ': </b>'; |
|
47 | 47 | /** Retrieve the property value **/ |
48 | 48 | $propertyValue = $objPHPExcel->getProperties()->getCustomPropertyValue($customPropertyName); |
49 | 49 | /** Retrieve the property type **/ |
50 | 50 | $propertyType = $objPHPExcel->getProperties()->getCustomPropertyType($customPropertyName); |
51 | 51 | |
52 | 52 | /** Manipulate properties as appropriate for display purposes **/ |
53 | - switch($propertyType) { |
|
53 | + switch ($propertyType) { |
|
54 | 54 | case 'i' : // integer |
55 | 55 | $propertyType = 'integer number'; |
56 | 56 | break; |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | $propertyType = 'string'; |
62 | 62 | break; |
63 | 63 | case 'd' : // date |
64 | - $propertyValue = date('l, d<\s\up>S</\s\up> F Y g:i A',$propertyValue); |
|
64 | + $propertyValue = date('l, d<\s\up>S</\s\up> F Y g:i A', $propertyValue); |
|
65 | 65 | $propertyType = 'date'; |
66 | 66 | break; |
67 | 67 | case 'b' : // boolean |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | break; |
71 | 71 | } |
72 | 72 | |
73 | - echo $propertyValue,' (',$propertyType,')<br />'; |
|
73 | + echo $propertyValue, ' (', $propertyType, ')<br />'; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 |
@@ -37,15 +37,15 @@ |
||
37 | 37 | |
38 | 38 | class MyReadFilter implements PHPExcel_Reader_IReadFilter |
39 | 39 | { |
40 | - public function readCell($column, $row, $worksheetName = '') { |
|
41 | - // Read rows 1 to 7 and columns A to E only |
|
42 | - if ($row >= 1 && $row <= 7) { |
|
43 | - if (in_array($column,range('A','E'))) { |
|
44 | - return true; |
|
45 | - } |
|
46 | - } |
|
47 | - return false; |
|
48 | - } |
|
40 | + public function readCell($column, $row, $worksheetName = '') { |
|
41 | + // Read rows 1 to 7 and columns A to E only |
|
42 | + if ($row >= 1 && $row <= 7) { |
|
43 | + if (in_array($column,range('A','E'))) { |
|
44 | + return true; |
|
45 | + } |
|
46 | + } |
|
47 | + return false; |
|
48 | + } |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | $filterSubset = new MyReadFilter(); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | public function readCell($column, $row, $worksheetName = '') { |
41 | 41 | // Read rows 1 to 7 and columns A to E only |
42 | 42 | if ($row >= 1 && $row <= 7) { |
43 | - if (in_array($column,range('A','E'))) { |
|
43 | + if (in_array($column, range('A', 'E'))) { |
|
44 | 44 | return true; |
45 | 45 | } |
46 | 46 | } |
@@ -51,9 +51,9 @@ discard block |
||
51 | 51 | $filterSubset = new MyReadFilter(); |
52 | 52 | |
53 | 53 | |
54 | -echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'<br />'; |
|
54 | +echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '<br />'; |
|
55 | 55 | $objReader = PHPExcel_IOFactory::createReader($inputFileType); |
56 | -echo 'Loading Sheet "',$sheetname,'" only<br />'; |
|
56 | +echo 'Loading Sheet "', $sheetname, '" only<br />'; |
|
57 | 57 | $objReader->setLoadSheetsOnly($sheetname); |
58 | 58 | echo 'Loading Sheet using filter<br />'; |
59 | 59 | $objReader->setReadFilter($filterSubset); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | echo '<hr />'; |
64 | 64 | |
65 | -$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); |
|
65 | +$sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true); |
|
66 | 66 | var_dump($sheetData); |
67 | 67 | |
68 | 68 |
@@ -27,13 +27,13 @@ |
||
27 | 27 | |
28 | 28 | |
29 | 29 | $inputFileName = './sampleData/example1.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 | $objPHPExcel = PHPExcel_IOFactory::load($inputFileName); |
32 | 32 | |
33 | 33 | |
34 | 34 | echo '<hr />'; |
35 | 35 | |
36 | -$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); |
|
36 | +$sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true); |
|
37 | 37 | var_dump($sheetData); |
38 | 38 | |
39 | 39 |
@@ -35,10 +35,10 @@ discard block |
||
35 | 35 | $objPHPExcel = $objReader->load($inputFileName); |
36 | 36 | $objPHPExcel->getActiveSheet()->setTitle(pathinfo($inputFileName,PATHINFO_BASENAME)); |
37 | 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)); |
|
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 | 42 | } |
43 | 43 | |
44 | 44 | |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | echo $objPHPExcel->getSheetCount(),' worksheet',(($objPHPExcel->getSheetCount() == 1) ? '' : 's'),' loaded<br /><br />'; |
48 | 48 | $loadedSheetNames = $objPHPExcel->getSheetNames(); |
49 | 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 />'; |
|
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 | 55 | } |
56 | 56 | |
57 | 57 |
@@ -27,29 +27,29 @@ |
||
27 | 27 | |
28 | 28 | |
29 | 29 | $inputFileType = 'CSV'; |
30 | -$inputFileNames = array('./sampleData/example1.csv','./sampleData/example2.csv'); |
|
30 | +$inputFileNames = array('./sampleData/example1.csv', './sampleData/example2.csv'); |
|
31 | 31 | |
32 | 32 | $objReader = PHPExcel_IOFactory::createReader($inputFileType); |
33 | 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 />'; |
|
34 | +echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' into WorkSheet #1 using IOFactory with a defined reader type of ', $inputFileType, '<br />'; |
|
35 | 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)); |
|
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 | 42 | } |
43 | 43 | |
44 | 44 | |
45 | 45 | echo '<hr />'; |
46 | 46 | |
47 | -echo $objPHPExcel->getSheetCount(),' worksheet',(($objPHPExcel->getSheetCount() == 1) ? '' : 's'),' loaded<br /><br />'; |
|
47 | +echo $objPHPExcel->getSheetCount(), ' worksheet', (($objPHPExcel->getSheetCount() == 1) ? '' : 's'), ' loaded<br /><br />'; |
|
48 | 48 | $loadedSheetNames = $objPHPExcel->getSheetNames(); |
49 | -foreach($loadedSheetNames as $sheetIndex => $loadedSheetName) { |
|
50 | - echo '<b>Worksheet #',$sheetIndex,' -> ',$loadedSheetName,'</b><br />'; |
|
49 | +foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) { |
|
50 | + echo '<b>Worksheet #', $sheetIndex, ' -> ', $loadedSheetName, '</b><br />'; |
|
51 | 51 | $objPHPExcel->setActiveSheetIndexByName($loadedSheetName); |
52 | - $sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); |
|
52 | + $sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true); |
|
53 | 53 | var_dump($sheetData); |
54 | 54 | echo '<br /><br />'; |
55 | 55 | } |
@@ -39,31 +39,31 @@ |
||
39 | 39 | echo $objPHPExcel->getSheetCount(),' worksheet',(($objPHPExcel->getSheetCount() == 1) ? '' : 's'),' loaded<br /><br />'; |
40 | 40 | $loadedSheetNames = $objPHPExcel->getSheetNames(); |
41 | 41 | foreach($loadedSheetNames as $sheetIndex => $loadedSheetName) { |
42 | - echo '<b>Worksheet #',$sheetIndex,' -> ',$loadedSheetName,' (Formatted)</b><br />'; |
|
43 | - $objPHPExcel->setActiveSheetIndexByName($loadedSheetName); |
|
44 | - $sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); |
|
45 | - var_dump($sheetData); |
|
46 | - echo '<br />'; |
|
42 | + echo '<b>Worksheet #',$sheetIndex,' -> ',$loadedSheetName,' (Formatted)</b><br />'; |
|
43 | + $objPHPExcel->setActiveSheetIndexByName($loadedSheetName); |
|
44 | + $sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); |
|
45 | + var_dump($sheetData); |
|
46 | + echo '<br />'; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | echo '<hr />'; |
50 | 50 | |
51 | 51 | foreach($loadedSheetNames as $sheetIndex => $loadedSheetName) { |
52 | - echo '<b>Worksheet #',$sheetIndex,' -> ',$loadedSheetName,' (Unformatted)</b><br />'; |
|
53 | - $objPHPExcel->setActiveSheetIndexByName($loadedSheetName); |
|
54 | - $sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,false,true); |
|
55 | - var_dump($sheetData); |
|
56 | - echo '<br />'; |
|
52 | + echo '<b>Worksheet #',$sheetIndex,' -> ',$loadedSheetName,' (Unformatted)</b><br />'; |
|
53 | + $objPHPExcel->setActiveSheetIndexByName($loadedSheetName); |
|
54 | + $sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,false,true); |
|
55 | + var_dump($sheetData); |
|
56 | + echo '<br />'; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | echo '<hr />'; |
60 | 60 | |
61 | 61 | foreach($loadedSheetNames as $sheetIndex => $loadedSheetName) { |
62 | - echo '<b>Worksheet #',$sheetIndex,' -> ',$loadedSheetName,' (Raw)</b><br />'; |
|
63 | - $objPHPExcel->setActiveSheetIndexByName($loadedSheetName); |
|
64 | - $sheetData = $objPHPExcel->getActiveSheet()->toArray(null,false,false,true); |
|
65 | - var_dump($sheetData); |
|
66 | - echo '<br />'; |
|
62 | + echo '<b>Worksheet #',$sheetIndex,' -> ',$loadedSheetName,' (Raw)</b><br />'; |
|
63 | + $objPHPExcel->setActiveSheetIndexByName($loadedSheetName); |
|
64 | + $sheetData = $objPHPExcel->getActiveSheet()->toArray(null,false,false,true); |
|
65 | + var_dump($sheetData); |
|
66 | + echo '<br />'; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | ?> |
@@ -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 |
@@ -46,7 +46,7 @@ |
||
46 | 46 | echo $objPHPExcel->getSheetCount(),' worksheet',(($objPHPExcel->getSheetCount() == 1) ? '' : 's'),' loaded<br /><br />'; |
47 | 47 | $loadedSheetNames = $objPHPExcel->getSheetNames(); |
48 | 48 | foreach($loadedSheetNames as $sheetIndex => $loadedSheetName) { |
49 | - echo $sheetIndex,' -> ',$loadedSheetName,'<br />'; |
|
49 | + echo $sheetIndex,' -> ',$loadedSheetName,'<br />'; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 |
@@ -37,23 +37,23 @@ discard block |
||
37 | 37 | /** Define a Read Filter class implementing PHPExcel_Reader_IReadFilter */ |
38 | 38 | class chunkReadFilter implements PHPExcel_Reader_IReadFilter |
39 | 39 | { |
40 | - private $_startRow = 0; |
|
41 | - |
|
42 | - private $_endRow = 0; |
|
43 | - |
|
44 | - /** We expect a list of the rows that we want to read to be passed into the constructor */ |
|
45 | - public function __construct($startRow, $chunkSize) { |
|
46 | - $this->_startRow = $startRow; |
|
47 | - $this->_endRow = $startRow + $chunkSize; |
|
48 | - } |
|
49 | - |
|
50 | - public function readCell($column, $row, $worksheetName = '') { |
|
51 | - // Only read the heading row, and the rows that were configured in the constructor |
|
52 | - if (($row == 1) || ($row >= $this->_startRow && $row < $this->_endRow)) { |
|
53 | - return true; |
|
54 | - } |
|
55 | - return false; |
|
56 | - } |
|
40 | + private $_startRow = 0; |
|
41 | + |
|
42 | + private $_endRow = 0; |
|
43 | + |
|
44 | + /** We expect a list of the rows that we want to read to be passed into the constructor */ |
|
45 | + public function __construct($startRow, $chunkSize) { |
|
46 | + $this->_startRow = $startRow; |
|
47 | + $this->_endRow = $startRow + $chunkSize; |
|
48 | + } |
|
49 | + |
|
50 | + public function readCell($column, $row, $worksheetName = '') { |
|
51 | + // Only read the heading row, and the rows that were configured in the constructor |
|
52 | + if (($row == 1) || ($row >= $this->_startRow && $row < $this->_endRow)) { |
|
53 | + return true; |
|
54 | + } |
|
55 | + return false; |
|
56 | + } |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | |
@@ -70,19 +70,19 @@ 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 />'; |
|
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); |
|
76 | - /** Tell the Reader that we want to use the new Read Filter that we've just Instantiated **/ |
|
77 | - $objReader->setReadFilter($chunkFilter); |
|
78 | - /** Load only the rows that match our filter from $inputFileName to a PHPExcel Object **/ |
|
79 | - $objPHPExcel = $objReader->load($inputFileName); |
|
80 | - |
|
81 | - // Do some processing here |
|
82 | - |
|
83 | - $sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); |
|
84 | - var_dump($sheetData); |
|
85 | - echo '<br /><br />'; |
|
73 | + echo 'Loading WorkSheet using configurable filter for headings row 1 and for rows ',$startRow,' to ',($startRow+$chunkSize-1),'<br />'; |
|
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); |
|
76 | + /** Tell the Reader that we want to use the new Read Filter that we've just Instantiated **/ |
|
77 | + $objReader->setReadFilter($chunkFilter); |
|
78 | + /** Load only the rows that match our filter from $inputFileName to a PHPExcel Object **/ |
|
79 | + $objPHPExcel = $objReader->load($inputFileName); |
|
80 | + |
|
81 | + // Do some processing here |
|
82 | + |
|
83 | + $sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); |
|
84 | + var_dump($sheetData); |
|
85 | + echo '<br /><br />'; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 |
@@ -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 | } |