@@ -33,20 +33,20 @@ discard block |
||
33 | 33 | |
34 | 34 | // Add some data |
35 | 35 | $testDates = array( array(3,15), array(13,15), array(15,15,15), array(3,15,30), |
36 | - array(15,15,15), array(5), array(9,15,0), array(9,15,-1), |
|
37 | - array(13,-14,-15), array(0,0,-1) |
|
38 | - ); |
|
36 | + array(15,15,15), array(5), array(9,15,0), array(9,15,-1), |
|
37 | + array(13,-14,-15), array(0,0,-1) |
|
38 | + ); |
|
39 | 39 | $testDateCount = count($testDates); |
40 | 40 | |
41 | 41 | $worksheet->fromArray($testDates,NULL,'A1',true); |
42 | 42 | |
43 | 43 | for ($row = 1; $row <= $testDateCount; ++$row) { |
44 | - $worksheet->setCellValue('D'.$row, '=TIME(A'.$row.',B'.$row.',C'.$row.')'); |
|
45 | - $worksheet->setCellValue('E'.$row, '=D'.$row); |
|
44 | + $worksheet->setCellValue('D'.$row, '=TIME(A'.$row.',B'.$row.',C'.$row.')'); |
|
45 | + $worksheet->setCellValue('E'.$row, '=D'.$row); |
|
46 | 46 | } |
47 | 47 | $worksheet->getStyle('E1:E'.$testDateCount) |
48 | - ->getNumberFormat() |
|
49 | - ->setFormatCode('hh:mm:ss'); |
|
48 | + ->getNumberFormat() |
|
49 | + ->setFormatCode('hh:mm:ss'); |
|
50 | 50 | |
51 | 51 | |
52 | 52 | echo '<hr />'; |
@@ -67,15 +67,15 @@ discard block |
||
67 | 67 | <th>Second</th> |
68 | 68 | <tr> |
69 | 69 | <?php |
70 | - for ($row = 1; $row <= $testDateCount; ++$row) { |
|
71 | - echo '<tr>'; |
|
72 | - echo '<td>' , $worksheet->getCell('A'.$row)->getFormattedValue() , '</td>'; |
|
73 | - echo '<td>' , $worksheet->getCell('B'.$row)->getFormattedValue() , '</td>'; |
|
74 | - echo '<td>' , $worksheet->getCell('C'.$row)->getFormattedValue() , '</td>'; |
|
75 | - echo '<td>' , $worksheet->getCell('D'.$row)->getValue() , '</td>'; |
|
76 | - echo '<td>' , $worksheet->getCell('D'.$row)->getFormattedValue() , '</td>'; |
|
77 | - echo '<td>' , $worksheet->getCell('E'.$row)->getFormattedValue() , '</td>'; |
|
78 | - echo '</tr>'; |
|
79 | - } |
|
80 | - ?> |
|
70 | + for ($row = 1; $row <= $testDateCount; ++$row) { |
|
71 | + echo '<tr>'; |
|
72 | + echo '<td>' , $worksheet->getCell('A'.$row)->getFormattedValue() , '</td>'; |
|
73 | + echo '<td>' , $worksheet->getCell('B'.$row)->getFormattedValue() , '</td>'; |
|
74 | + echo '<td>' , $worksheet->getCell('C'.$row)->getFormattedValue() , '</td>'; |
|
75 | + echo '<td>' , $worksheet->getCell('D'.$row)->getValue() , '</td>'; |
|
76 | + echo '<td>' , $worksheet->getCell('D'.$row)->getFormattedValue() , '</td>'; |
|
77 | + echo '<td>' , $worksheet->getCell('E'.$row)->getFormattedValue() , '</td>'; |
|
78 | + echo '</tr>'; |
|
79 | + } |
|
80 | + ?> |
|
81 | 81 | </table> |
82 | 82 | \ No newline at end of file |
@@ -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 | ?> |