@@ -33,18 +33,18 @@ discard block |
||
33 | 33 | |
34 | 34 | // Add some data |
35 | 35 | $testDates = array( '3:15', '13:15', '15:15:15', '3:15 AM', '3:15 PM', '5PM', '9:15AM', '13:15AM' |
36 | - ); |
|
36 | + ); |
|
37 | 37 | $testDateCount = count($testDates); |
38 | 38 | |
39 | 39 | for($row = 1; $row <= $testDateCount; ++$row) { |
40 | - $worksheet->setCellValue('A'.$row, $testDates[$row-1]); |
|
41 | - $worksheet->setCellValue('B'.$row, '=TIMEVALUE(A'.$row.')'); |
|
42 | - $worksheet->setCellValue('C'.$row, '=B'.$row); |
|
40 | + $worksheet->setCellValue('A'.$row, $testDates[$row-1]); |
|
41 | + $worksheet->setCellValue('B'.$row, '=TIMEVALUE(A'.$row.')'); |
|
42 | + $worksheet->setCellValue('C'.$row, '=B'.$row); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | $worksheet->getStyle('C1:C'.$testDateCount) |
46 | - ->getNumberFormat() |
|
47 | - ->setFormatCode('hh:mm:ss'); |
|
46 | + ->getNumberFormat() |
|
47 | + ->setFormatCode('hh:mm:ss'); |
|
48 | 48 | |
49 | 49 | |
50 | 50 | echo '<hr />'; |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | <th>Formatted TimeStamp</th> |
61 | 61 | </tr> |
62 | 62 | <?php |
63 | - for ($row = 1; $row <= $testDateCount; ++$row) { |
|
64 | - echo '<tr>'; |
|
65 | - echo '<td>' , $worksheet->getCell('A'.$row)->getFormattedValue() , '</td>'; |
|
66 | - echo '<td>' , $worksheet->getCell('B'.$row)->getValue() , '</td>'; |
|
67 | - echo '<td>' , $worksheet->getCell('B'.$row)->getFormattedValue() , '</td>'; |
|
68 | - echo '<td>' , $worksheet->getCell('C'.$row)->getFormattedValue() , '</td>'; |
|
69 | - echo '</tr>'; |
|
70 | - } |
|
71 | - ?> |
|
63 | + for ($row = 1; $row <= $testDateCount; ++$row) { |
|
64 | + echo '<tr>'; |
|
65 | + echo '<td>' , $worksheet->getCell('A'.$row)->getFormattedValue() , '</td>'; |
|
66 | + echo '<td>' , $worksheet->getCell('B'.$row)->getValue() , '</td>'; |
|
67 | + echo '<td>' , $worksheet->getCell('B'.$row)->getFormattedValue() , '</td>'; |
|
68 | + echo '<td>' , $worksheet->getCell('C'.$row)->getFormattedValue() , '</td>'; |
|
69 | + echo '</tr>'; |
|
70 | + } |
|
71 | + ?> |
|
72 | 72 | </table> |
73 | 73 | \ No newline at end of file |
@@ -23,27 +23,27 @@ |
||
23 | 23 | |
24 | 24 | foreach($exampleTypeList as $exampleType) { |
25 | 25 | |
26 | - echo '<h2>' . pathinfo($exampleType,PATHINFO_BASENAME) . ' Function Examples</h2>'; |
|
26 | + echo '<h2>' . pathinfo($exampleType,PATHINFO_BASENAME) . ' Function Examples</h2>'; |
|
27 | 27 | |
28 | - $exampleList = glob('./'.$exampleType.'/*.php'); |
|
28 | + $exampleList = glob('./'.$exampleType.'/*.php'); |
|
29 | 29 | |
30 | - foreach($exampleList as $exampleFile) { |
|
31 | - $fileData = file_get_contents($exampleFile); |
|
30 | + foreach($exampleList as $exampleFile) { |
|
31 | + $fileData = file_get_contents($exampleFile); |
|
32 | 32 | |
33 | - $h1Pattern = '#<h1>(.*?)</h1>#'; |
|
34 | - $h2Pattern = '#<h2>(.*?)</h2>#'; |
|
33 | + $h1Pattern = '#<h1>(.*?)</h1>#'; |
|
34 | + $h2Pattern = '#<h2>(.*?)</h2>#'; |
|
35 | 35 | |
36 | - if (preg_match($h1Pattern, $fileData, $out)) { |
|
37 | - $h1Text = $out[1]; |
|
38 | - $h2Text = (preg_match($h2Pattern, $fileData, $out)) ? $out[1] : ''; |
|
36 | + if (preg_match($h1Pattern, $fileData, $out)) { |
|
37 | + $h1Text = $out[1]; |
|
38 | + $h2Text = (preg_match($h2Pattern, $fileData, $out)) ? $out[1] : ''; |
|
39 | 39 | |
40 | - echo '<a href="',$exampleFile,'">',$h1Text,'</a><br />'; |
|
41 | - if ($h2Text > '') { |
|
42 | - echo $h2Text,'<br />'; |
|
43 | - } |
|
44 | - } |
|
40 | + echo '<a href="',$exampleFile,'">',$h1Text,'</a><br />'; |
|
41 | + if ($h2Text > '') { |
|
42 | + echo $h2Text,'<br />'; |
|
43 | + } |
|
44 | + } |
|
45 | 45 | |
46 | - } |
|
46 | + } |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | ?> |
@@ -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 |
@@ -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 |
@@ -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 |
@@ -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(); |
@@ -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 |
@@ -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 | ?> |
@@ -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 |