| 1 |
<?php |
| 2 |
|
| 3 |
use PhpOffice\PhpSpreadsheet\IOFactory; |
| 4 |
|
| 5 |
require __DIR__ . '/../Header.php'; |
| 6 |
|
| 7 |
$inputFileType = 'Xls'; |
| 8 |
$inputFileName = __DIR__ . '/sampleData/example1.xls'; |
| 9 |
|
| 10 |
// Create a new Reader of the type defined in $inputFileType |
| 11 |
$reader = IOFactory::createReader($inputFileType); |
| 12 |
// Load $inputFileName to a PhpSpreadsheet Object |
| 13 |
$spreadsheet = $reader->load($inputFileName); |
| 14 |
|
| 15 |
// Read the document's creator property |
| 16 |
$creator = $spreadsheet->getProperties()->getCreator(); |
| 17 |
$helper->log('<b>Document Creator: </b>' . $creator); |
| 18 |
|
| 19 |
// Read the Date when the workbook was created (as a PHP timestamp value) |
| 20 |
$creationDatestamp = $spreadsheet->getProperties()->getCreated(); |
| 21 |
// Format the date and time using the standard PHP date() function |
| 22 |
$creationDate = date('l, d<\s\up>S</\s\up> F Y', $creationDatestamp); |
| 23 |
$creationTime = date('g:i A', $creationDatestamp); |
| 24 |
$helper->log('<b>Created On: </b>' . $creationDate . ' at ' . $creationTime); |
| 25 |
|
| 26 |
// Read the name of the last person to modify this workbook |
| 27 |
$modifiedBy = $spreadsheet->getProperties()->getLastModifiedBy(); |
| 28 |
$helper->log('<b>Last Modified By: </b>' . $modifiedBy); |
| 29 |
|
| 30 |
// Read the Date when the workbook was last modified (as a PHP timestamp value) |
| 31 |
$modifiedDatestamp = $spreadsheet->getProperties()->getModified(); |
| 32 |
// Format the date and time using the standard PHP date() function |
| 33 |
$modifiedDate = date('l, d<\s\up>S</\s\up> F Y', $modifiedDatestamp); |
| 34 |
$modifiedTime = date('g:i A', $modifiedDatestamp); |
| 35 |
$helper->log('<b>Last Modified On: </b>' . $modifiedDate . ' at ' . $modifiedTime); |
| 36 |
|
| 37 |
// Read the workbook title property |
| 38 |
$workbookTitle = $spreadsheet->getProperties()->getTitle(); |
| 39 |
$helper->log('<b>Title: </b>' . $workbookTitle); |
| 40 |
|
| 41 |
// Read the workbook description property |
| 42 |
$description = $spreadsheet->getProperties()->getDescription(); |
| 43 |
$helper->log('<b>Description: </b>' . $description); |
| 44 |
|
| 45 |
// Read the workbook subject property |
| 46 |
$subject = $spreadsheet->getProperties()->getSubject(); |
| 47 |
$helper->log('<b>Subject: </b>' . $subject); |
| 48 |
|
| 49 |
// Read the workbook keywords property |
| 50 |
$keywords = $spreadsheet->getProperties()->getKeywords(); |
| 51 |
$helper->log('<b>Keywords: </b>' . $keywords); |
| 52 |
|
| 53 |
// Read the workbook category property |
| 54 |
$category = $spreadsheet->getProperties()->getCategory(); |
| 55 |
$helper->log('<b>Category: </b>' . $category); |
| 56 |
|
| 57 |
// Read the workbook company property |
| 58 |
$company = $spreadsheet->getProperties()->getCompany(); |
| 59 |
$helper->log('<b>Company: </b>' . $company); |
| 60 |
|
| 61 |
// Read the workbook manager property |
| 62 |
$manager = $spreadsheet->getProperties()->getManager(); |
| 63 |
$helper->log('<b>Manager: </b>' . $manager); |
| 64 |
$s = new \PhpOffice\PhpSpreadsheet\Helper\Sample(); |
| 65 |
|