Merge branch 'master' into moredatefilter

This commit is contained in:
oleibman 2021-06-02 20:50:05 -07:00 committed by GitHub
commit 300ea99e93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 101 additions and 18 deletions

View File

@ -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

View File

@ -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)

View File

@ -14,7 +14,7 @@
<Description>Some comments about the PHPExcel Gnumeric Reader</Description>
<LastAuthor>Owen Leibman</LastAuthor>
<Created>2010-09-02T20:48:39Z</Created>
<LastSaved>2010-09-02T20:48:39Z</LastSaved>
<LastSaved>2010-09-03T21:48:39Z</LastSaved>
<Category>PHPExcel Xml Reader Test Category</Category>
<Manager>Maarten Balliauw</Manager>
<Company>PHPExcel</Company>

View File

@ -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':

View File

@ -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('<xml></xml>')
: ($simple->attributes($node) ?? new SimpleXMLElement('<xml></xml>'));
}
protected function processTimestampValue(string $dateTimeValue): int
{
$dateTime = strtotime($dateTimeValue);
return $dateTime === false ? time() : $dateTime;
}
}

View File

@ -0,0 +1,53 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PHPUnit\Framework\TestCase;
class MergedCellTest extends TestCase
{
/**
* @var Spreadsheet
*/
protected $spreadSheet;
protected function setUp(): void
{
$this->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()],
];
}
}

View File

@ -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());

View File

@ -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());