diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index 3bdeea1d..a7850833 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -19,7 +19,7 @@ jobs: - name: Build API documentation run: | - curl -LO https://github.com/phpDocumentor/phpDocumentor/releases/download/v3.0.0-rc/phpDocumentor.phar + curl -LO https://github.com/phpDocumentor/phpDocumentor/releases/download/v3.0.0/phpDocumentor.phar php phpDocumentor.phar --directory src/ --target docs/api - name: Deploy to GithHub Pages diff --git a/CHANGELOG.md b/CHANGELOG.md index 83e25edb..5e9eec11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,28 @@ and this project adheres to [Semantic Versioning](https://semver.org). ### Added +- Nothing. + +### Changed + +- Nothing. + +### Deprecated + +- Nothing. + +### Removed + +- Nothing. + +### Fixed + +- Nothing. + +## 1.18.0 - 2021-05-31 + +### Added +- Enhancements to CSV Reader, allowing options to be set when using `IOFactory::load()` with a callback to set delimiter, enclosure, charset etc. [PR #2103](https://github.com/PHPOffice/PhpSpreadsheet/pull/2103) - See [documentation](https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/reading-and-writing-to-file.md#csv-comma-separated-values) for details. - Implemented basic AutoFiltering for Ods Reader and Writer [PR #2053](https://github.com/PHPOffice/PhpSpreadsheet/pull/2053) - Implemented basic AutoFiltering for Gnumeric Reader [PR #2055](https://github.com/PHPOffice/PhpSpreadsheet/pull/2055) - Improved support for Row and Column ranges in formulae [Issue #1755](https://github.com/PHPOffice/PhpSpreadsheet/issues/1755) [PR #2028](https://github.com/PHPOffice/PhpSpreadsheet/pull/2028) diff --git a/samples/templates/excel2003.xml b/samples/templates/excel2003.xml index cd1188a7..5e0268f9 100644 --- a/samples/templates/excel2003.xml +++ b/samples/templates/excel2003.xml @@ -14,7 +14,7 @@ Some comments about the PHPExcel Gnumeric Reader Owen Leibman 2010-09-02T20:48:39Z - 2010-09-02T20:48:39Z + 2010-09-03T21:48:39Z PHPExcel Xml Reader Test Category Maarten Balliauw PHPExcel diff --git a/src/PhpSpreadsheet/Reader/Gnumeric/Properties.php b/src/PhpSpreadsheet/Reader/Gnumeric/Properties.php index c466a859..ddcf77f1 100644 --- a/src/PhpSpreadsheet/Reader/Gnumeric/Properties.php +++ b/src/PhpSpreadsheet/Reader/Gnumeric/Properties.php @@ -78,9 +78,7 @@ class Properties break; case 'date': - $creationDate = strtotime($propertyValue); - $creationDate = $creationDate === false ? time() : $creationDate; - $docProps->setCreated($creationDate); + $creationDate = $propertyValue; $docProps->setModified($creationDate); break; @@ -110,10 +108,8 @@ class Properties break; case 'creation-date': - $creationDate = strtotime($propertyValue); - $creationDate = $creationDate === false ? time() : $creationDate; + $creationDate = $propertyValue; $docProps->setCreated($creationDate); - $docProps->setModified($creationDate); break; case 'user-defined': diff --git a/src/PhpSpreadsheet/Reader/Xml/Properties.php b/src/PhpSpreadsheet/Reader/Xml/Properties.php index fa0d7957..1c3e421a 100644 --- a/src/PhpSpreadsheet/Reader/Xml/Properties.php +++ b/src/PhpSpreadsheet/Reader/Xml/Properties.php @@ -70,7 +70,7 @@ class Properties break; case 'Created': - $docProps->setCreated($this->processTimestampValue($stringValue)); + $docProps->setCreated($stringValue); break; case 'LastAuthor': @@ -78,7 +78,7 @@ class Properties break; case 'LastSaved': - $docProps->setModified($this->processTimestampValue($stringValue)); + $docProps->setModified($stringValue); break; case 'Company': @@ -135,7 +135,7 @@ class Properties break; case 'dateTime.tz': $propertyType = DocumentProperties::PROPERTY_TYPE_DATE; - $propertyValue = $this->processTimestampValue(trim((string) $propertyValue)); + $propertyValue = trim((string) $propertyValue); break; } @@ -154,11 +154,4 @@ class Properties ? new SimpleXMLElement('') : ($simple->attributes($node) ?? new SimpleXMLElement('')); } - - protected function processTimestampValue(string $dateTimeValue): int - { - $dateTime = strtotime($dateTimeValue); - - return $dateTime === false ? time() : $dateTime; - } } diff --git a/tests/PhpSpreadsheetTests/Calculation/MergedCellTest.php b/tests/PhpSpreadsheetTests/Calculation/MergedCellTest.php new file mode 100644 index 00000000..6a710436 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/MergedCellTest.php @@ -0,0 +1,53 @@ +spreadSheet = new Spreadsheet(); + + $dataSheet = $this->spreadSheet->getActiveSheet(); + $dataSheet->setCellValue('A1', 1.1); + $dataSheet->setCellValue('A2', 2.2); + $dataSheet->mergeCells('A2:A4'); + $dataSheet->setCellValue('A5', 3.3); + } + + /** + * @param mixed $expectedResult + * + * @dataProvider providerWorksheetFormulae + */ + public function testMergedCellBehaviour(string $formula, $expectedResult): void + { + $worksheet = $this->spreadSheet->getActiveSheet(); + + $worksheet->setCellValue('A7', $formula); + + $result = $worksheet->getCell('A7')->getCalculatedValue(); + self::assertSame($expectedResult, $result); + } + + public function providerWorksheetFormulae(): array + { + return [ + ['=SUM(A1:A5)', 6.6], + ['=COUNT(A1:A5)', 3], + ['=COUNTA(A1:A5)', 3], + ['=SUM(A3:A4)', 0], + ['=A2+A3+A4', 2.2], + ['=A2/A3', Functions::DIV0()], + ]; + } +} diff --git a/tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericLoadTest.php b/tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericLoadTest.php index 9544fc3a..58dbe501 100644 --- a/tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericLoadTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericLoadTest.php @@ -2,7 +2,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Reader\Gnumeric; +use DateTimeZone; use PhpOffice\PhpSpreadsheet\Reader\Gnumeric; +use PhpOffice\PhpSpreadsheet\Shared\Date; use PhpOffice\PhpSpreadsheet\Style\Border; use PhpOffice\PhpSpreadsheet\Style\Borders; use PhpOffice\PhpSpreadsheet\Style\Color; @@ -26,6 +28,12 @@ class GnumericLoadTest extends TestCase self::assertEquals('BCD', $sheet->getCell('A4')->getValue()); $props = $spreadsheet->getProperties(); self::assertEquals('Mark Baker', $props->getCreator()); + $creationDate = $props->getCreated(); + $result = Date::formattedDateTimeFromTimestamp("$creationDate", 'Y-m-d\\TH:i:s\\Z', new DateTimeZone('UTC')); + self::assertEquals('2010-09-02T20:48:39Z', $result); + $creationDate = $props->getModified(); + $result = Date::formattedDateTimeFromTimestamp("$creationDate", 'Y-m-d\\TH:i:s\\Z', new DateTimeZone('UTC')); + self::assertEquals('2020-06-05T05:15:21Z', $result); $sheet = $spreadsheet->getSheet(0); self::assertEquals('Sample Data', $sheet->getTitle()); diff --git a/tests/PhpSpreadsheetTests/Reader/Xml/XmlLoadTest.php b/tests/PhpSpreadsheetTests/Reader/Xml/XmlLoadTest.php index 3783c1a9..29d81299 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xml/XmlLoadTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xml/XmlLoadTest.php @@ -2,7 +2,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Reader\Xml; +use DateTimeZone; use PhpOffice\PhpSpreadsheet\Reader\Xml; +use PhpOffice\PhpSpreadsheet\Shared\Date; use PHPUnit\Framework\TestCase; class XmlLoadTest extends TestCase @@ -21,8 +23,17 @@ class XmlLoadTest extends TestCase self::assertEquals('BCD', $sheet->getCell('A4')->getValue()); $props = $spreadsheet->getProperties(); self::assertEquals('Mark Baker', $props->getCreator()); + $creationDate = $props->getCreated(); + $result = Date::formattedDateTimeFromTimestamp("$creationDate", 'Y-m-d\\TH:i:s\\Z', new DateTimeZone('UTC')); + self::assertEquals('2010-09-02T20:48:39Z', $result); + $creationDate = $props->getModified(); + $result = Date::formattedDateTimeFromTimestamp("$creationDate", 'Y-m-d\\TH:i:s\\Z', new DateTimeZone('UTC')); + self::assertEquals('2010-09-03T21:48:39Z', $result); self::assertEquals('AbCd1234', $props->getCustomPropertyValue('my_API_Token')); self::assertEquals('2', $props->getCustomPropertyValue('myڐInt')); + $creationDate = $props->getCustomPropertyValue('my_API_Token_Expiry'); + $result = Date::formattedDateTimeFromTimestamp("$creationDate", 'Y-m-d\\TH:i:s\\Z', new DateTimeZone('UTC')); + self::assertEquals('2019-01-31T07:00:00Z', $result); $sheet = $spreadsheet->getSheet(0); self::assertEquals('Sample Data', $sheet->getTitle());