@@ -32,19 +32,19 @@ discard block |
||
32 | 32 | $worksheet = $objPHPExcel->getActiveSheet(); |
33 | 33 | |
34 | 34 | // Add some data |
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) |
|
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 | 38 | ); |
39 | 39 | $testDateCount = count($testDates); |
40 | 40 | |
41 | -$worksheet->fromArray($testDates,NULL,'A1',true); |
|
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 | -$worksheet->getStyle('E1:E'.$testDateCount) |
|
47 | +$worksheet->getStyle('E1:E' . $testDateCount) |
|
48 | 48 | ->getNumberFormat() |
49 | 49 | ->setFormatCode('hh:mm:ss'); |
50 | 50 | |
@@ -69,12 +69,12 @@ discard block |
||
69 | 69 | <?php |
70 | 70 | for ($row = 1; $row <= $testDateCount; ++$row) { |
71 | 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>'; |
|
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 | 78 | echo '</tr>'; |
79 | 79 | } |
80 | 80 | ?> |
@@ -32,17 +32,17 @@ discard block |
||
32 | 32 | $worksheet = $objPHPExcel->getActiveSheet(); |
33 | 33 | |
34 | 34 | // Add some data |
35 | -$testDates = array( '3:15', '13:15', '15:15:15', '3:15 AM', '3:15 PM', '5PM', '9:15AM', '13:15AM' |
|
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 | -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); |
|
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); |
|
43 | 43 | } |
44 | 44 | |
45 | -$worksheet->getStyle('C1:C'.$testDateCount) |
|
45 | +$worksheet->getStyle('C1:C' . $testDateCount) |
|
46 | 46 | ->getNumberFormat() |
47 | 47 | ->setFormatCode('hh:mm:ss'); |
48 | 48 | |
@@ -62,10 +62,10 @@ discard block |
||
62 | 62 | <?php |
63 | 63 | for ($row = 1; $row <= $testDateCount; ++$row) { |
64 | 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>'; |
|
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 | 69 | echo '</tr>'; |
70 | 70 | } |
71 | 71 | ?> |
@@ -19,15 +19,15 @@ discard block |
||
19 | 19 | |
20 | 20 | echo '<h1>PHPExcel Calculation Function Examples</h1>'; |
21 | 21 | |
22 | -$exampleTypeList = glob('./*',GLOB_ONLYDIR); |
|
22 | +$exampleTypeList = glob('./*', GLOB_ONLYDIR); |
|
23 | 23 | |
24 | -foreach($exampleTypeList as $exampleType) { |
|
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) { |
|
30 | + foreach ($exampleList as $exampleFile) { |
|
31 | 31 | $fileData = file_get_contents($exampleFile); |
32 | 32 | |
33 | 33 | $h1Pattern = '#<h1>(.*?)</h1>#'; |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | $h1Text = $out[1]; |
38 | 38 | $h2Text = (preg_match($h2Pattern, $fileData, $out)) ? $out[1] : ''; |
39 | 39 | |
40 | - echo '<a href="',$exampleFile,'">',$h1Text,'</a><br />'; |
|
40 | + echo '<a href="', $exampleFile, '">', $h1Text, '</a><br />'; |
|
41 | 41 | if ($h2Text > '') { |
42 | - echo $h2Text,'<br />'; |
|
42 | + echo $h2Text, '<br />'; |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 |
@@ -39,53 +39,53 @@ |
||
39 | 39 | |
40 | 40 | /** Read the document's creator property **/ |
41 | 41 | $creator = $objPHPExcel->getProperties()->getCreator(); |
42 | -echo '<b>Document Creator: </b>',$creator,'<br />'; |
|
42 | +echo '<b>Document Creator: </b>', $creator, '<br />'; |
|
43 | 43 | |
44 | 44 | /** Read the Date when the workbook was created (as a PHP timestamp value) **/ |
45 | 45 | $creationDatestamp = $objPHPExcel->getProperties()->getCreated(); |
46 | 46 | /** Format the date and time using the standard PHP date() function **/ |
47 | -$creationDate = date('l, d<\s\up>S</\s\up> F Y',$creationDatestamp); |
|
48 | -$creationTime = date('g:i A',$creationDatestamp); |
|
49 | -echo '<b>Created On: </b>',$creationDate,' at ',$creationTime,'<br />'; |
|
47 | +$creationDate = date('l, d<\s\up>S</\s\up> F Y', $creationDatestamp); |
|
48 | +$creationTime = date('g:i A', $creationDatestamp); |
|
49 | +echo '<b>Created On: </b>', $creationDate, ' at ', $creationTime, '<br />'; |
|
50 | 50 | |
51 | 51 | /** Read the name of the last person to modify this workbook **/ |
52 | 52 | $modifiedBy = $objPHPExcel->getProperties()->getLastModifiedBy(); |
53 | -echo '<b>Last Modified By: </b>',$modifiedBy,'<br />'; |
|
53 | +echo '<b>Last Modified By: </b>', $modifiedBy, '<br />'; |
|
54 | 54 | |
55 | 55 | /** Read the Date when the workbook was last modified (as a PHP timestamp value) **/ |
56 | 56 | $modifiedDatestamp = $objPHPExcel->getProperties()->getModified(); |
57 | 57 | /** Format the date and time using the standard PHP date() function **/ |
58 | -$modifiedDate = date('l, d<\s\up>S</\s\up> F Y',$modifiedDatestamp); |
|
59 | -$modifiedTime = date('g:i A',$modifiedDatestamp); |
|
60 | -echo '<b>Last Modified On: </b>',$modifiedDate,' at ',$modifiedTime,'<br />'; |
|
58 | +$modifiedDate = date('l, d<\s\up>S</\s\up> F Y', $modifiedDatestamp); |
|
59 | +$modifiedTime = date('g:i A', $modifiedDatestamp); |
|
60 | +echo '<b>Last Modified On: </b>', $modifiedDate, ' at ', $modifiedTime, '<br />'; |
|
61 | 61 | |
62 | 62 | /** Read the workbook title property **/ |
63 | 63 | $workbookTitle = $objPHPExcel->getProperties()->getTitle(); |
64 | -echo '<b>Title: </b>',$workbookTitle,'<br />'; |
|
64 | +echo '<b>Title: </b>', $workbookTitle, '<br />'; |
|
65 | 65 | |
66 | 66 | /** Read the workbook description property **/ |
67 | 67 | $description = $objPHPExcel->getProperties()->getDescription(); |
68 | -echo '<b>Description: </b>',$description,'<br />'; |
|
68 | +echo '<b>Description: </b>', $description, '<br />'; |
|
69 | 69 | |
70 | 70 | /** Read the workbook subject property **/ |
71 | 71 | $subject = $objPHPExcel->getProperties()->getSubject(); |
72 | -echo '<b>Subject: </b>',$subject,'<br />'; |
|
72 | +echo '<b>Subject: </b>', $subject, '<br />'; |
|
73 | 73 | |
74 | 74 | /** Read the workbook keywords property **/ |
75 | 75 | $keywords = $objPHPExcel->getProperties()->getKeywords(); |
76 | -echo '<b>Keywords: </b>',$keywords,'<br />'; |
|
76 | +echo '<b>Keywords: </b>', $keywords, '<br />'; |
|
77 | 77 | |
78 | 78 | /** Read the workbook category property **/ |
79 | 79 | $category = $objPHPExcel->getProperties()->getCategory(); |
80 | -echo '<b>Category: </b>',$category,'<br />'; |
|
80 | +echo '<b>Category: </b>', $category, '<br />'; |
|
81 | 81 | |
82 | 82 | /** Read the workbook company property **/ |
83 | 83 | $company = $objPHPExcel->getProperties()->getCompany(); |
84 | -echo '<b>Company: </b>',$company,'<br />'; |
|
84 | +echo '<b>Company: </b>', $company, '<br />'; |
|
85 | 85 | |
86 | 86 | /** Read the workbook manager property **/ |
87 | 87 | $manager = $objPHPExcel->getProperties()->getManager(); |
88 | -echo '<b>Manager: </b>',$manager,'<br />'; |
|
88 | +echo '<b>Manager: </b>', $manager, '<br />'; |
|
89 | 89 | |
90 | 90 | |
91 | 91 | ?> |
@@ -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 |
@@ -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 |
@@ -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 |
@@ -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 |