| 
									
										
										
										
											2017-10-01 08:48:59 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | use PhpOffice\PhpSpreadsheet\IOFactory; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | require __DIR__ . '/../Header.php'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $inputFileType = 'Xlsx'; | 
					
						
							|  |  |  | $inputFileName = __DIR__ . '/sampleData/example1.xlsx'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-01 11:07:04 +00:00
										 |  |  | // Create a new Reader of the type defined in $inputFileType
 | 
					
						
							| 
									
										
										
										
											2017-10-01 08:48:59 +00:00
										 |  |  | $reader = IOFactory::createReader($inputFileType); | 
					
						
							| 
									
										
										
										
											2017-10-01 11:07:04 +00:00
										 |  |  | // Load $inputFileName to a PhpSpreadsheet Object
 | 
					
						
							| 
									
										
										
										
											2017-10-01 08:48:59 +00:00
										 |  |  | $spreadsheet = $reader->load($inputFileName); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-01 11:07:04 +00:00
										 |  |  | // Read an array list of any custom properties for this document
 | 
					
						
							| 
									
										
										
										
											2017-10-01 08:48:59 +00:00
										 |  |  | $customPropertyList = $spreadsheet->getProperties()->getCustomProperties(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-01 11:07:04 +00:00
										 |  |  | // Loop through the list of custom properties
 | 
					
						
							| 
									
										
										
										
											2017-10-01 08:48:59 +00:00
										 |  |  | foreach ($customPropertyList as $customPropertyName) { | 
					
						
							|  |  |  |     $helper->log('<b>' . $customPropertyName . ': </b>'); | 
					
						
							| 
									
										
										
										
											2017-10-01 11:07:04 +00:00
										 |  |  |     // Retrieve the property value
 | 
					
						
							| 
									
										
										
										
											2017-10-01 08:48:59 +00:00
										 |  |  |     $propertyValue = $spreadsheet->getProperties()->getCustomPropertyValue($customPropertyName); | 
					
						
							| 
									
										
										
										
											2017-10-01 11:07:04 +00:00
										 |  |  |     // Retrieve the property type
 | 
					
						
							| 
									
										
										
										
											2017-10-01 08:48:59 +00:00
										 |  |  |     $propertyType = $spreadsheet->getProperties()->getCustomPropertyType($customPropertyName); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-01 11:07:04 +00:00
										 |  |  |     // Manipulate properties as appropriate for display purposes
 | 
					
						
							| 
									
										
										
										
											2017-10-01 08:48:59 +00:00
										 |  |  |     switch ($propertyType) { | 
					
						
							| 
									
										
										
										
											2018-08-06 02:02:16 +00:00
										 |  |  |         case 'i':    // integer
 | 
					
						
							| 
									
										
										
										
											2017-10-01 08:48:59 +00:00
										 |  |  |             $propertyType = 'integer number'; | 
					
						
							| 
									
										
										
										
											2017-10-01 11:07:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-01 08:48:59 +00:00
										 |  |  |             break; | 
					
						
							| 
									
										
										
										
											2018-08-06 02:02:16 +00:00
										 |  |  |         case 'f':    // float
 | 
					
						
							| 
									
										
										
										
											2017-10-01 08:48:59 +00:00
										 |  |  |             $propertyType = 'floating point number'; | 
					
						
							| 
									
										
										
										
											2017-10-01 11:07:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-01 08:48:59 +00:00
										 |  |  |             break; | 
					
						
							| 
									
										
										
										
											2018-08-06 02:02:16 +00:00
										 |  |  |         case 's':    // string
 | 
					
						
							| 
									
										
										
										
											2017-10-01 08:48:59 +00:00
										 |  |  |             $propertyType = 'string'; | 
					
						
							| 
									
										
										
										
											2017-10-01 11:07:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-01 08:48:59 +00:00
										 |  |  |             break; | 
					
						
							| 
									
										
										
										
											2018-08-06 02:02:16 +00:00
										 |  |  |         case 'd':    // date
 | 
					
						
							| 
									
										
										
										
											2017-10-01 08:48:59 +00:00
										 |  |  |             $propertyValue = date('l, d<\s\up>S</\s\up> F Y g:i A', $propertyValue); | 
					
						
							|  |  |  |             $propertyType = 'date'; | 
					
						
							| 
									
										
										
										
											2017-10-01 11:07:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-01 08:48:59 +00:00
										 |  |  |             break; | 
					
						
							| 
									
										
										
										
											2018-08-06 02:02:16 +00:00
										 |  |  |         case 'b':    // boolean
 | 
					
						
							| 
									
										
										
										
											2017-10-01 08:48:59 +00:00
										 |  |  |             $propertyValue = ($propertyValue) ? 'TRUE' : 'FALSE'; | 
					
						
							|  |  |  |             $propertyType = 'boolean'; | 
					
						
							| 
									
										
										
										
											2017-10-01 11:07:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-01 08:48:59 +00:00
										 |  |  |             break; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $helper->log($propertyValue . ' (' . $propertyType . ')'); | 
					
						
							|  |  |  | } |