From bc8caf4c4e1dc09ef89a0961f62b2f7867b8a663 Mon Sep 17 00:00:00 2001 From: aVadim Date: Tue, 22 Oct 2024 23:07:05 +0300 Subject: [PATCH] fix date formats; update dependencies --- composer.json | 5 ++--- src/FastExcelTemplator/Sheet.php | 8 ++------ tests/FastExcelTemplatorTest.php | 2 +- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 1ac9746..d2abf27 100644 --- a/composer.json +++ b/composer.json @@ -25,12 +25,11 @@ "ext-zip": "*", "ext-json": "*", "ext-mbstring": "*", - "ext-intl": "*", "ext-xmlreader": "*", "ext-dom": "*", "avadim/fast-excel-helper": "^1.2", - "avadim/fast-excel-writer": "^5.5.2", - "avadim/fast-excel-reader": "^2.16" + "avadim/fast-excel-writer": "^6.1", + "avadim/fast-excel-reader": "^2.20" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/src/FastExcelTemplator/Sheet.php b/src/FastExcelTemplator/Sheet.php index 303671d..09492ff 100644 --- a/src/FastExcelTemplator/Sheet.php +++ b/src/FastExcelTemplator/Sheet.php @@ -62,7 +62,7 @@ public function __construct($sheetName, $sheetId, $file, $path, $excel) */ public function path(): string { - return $this->path; + return $this->pathInZip; } /** @@ -250,7 +250,7 @@ protected function getRowTemplateReader(int $rowNumberMin, int $rowNumberMax): R } if (empty($this->rowTemplateReader)) { $this->rowTemplateReader = Excel::createReader($this->zipFilename); - $this->rowTemplateReader->openZip($this->path); + $this->rowTemplateReader->openZip($this->path()); } return $this->rowTemplateReader; @@ -480,10 +480,6 @@ private function _writeWithStyle($cellAddress, $cellAddressIdx, $cellData) if (!empty($cellData['f'])) { $this->sheetWriter->_writeToCellByIdx($cellAddressIdx, $cellData['f']); } - elseif ($cellData['t'] === 'date' && is_numeric($cellData['o'])) { - $this->sheetWriter->_writeToCellByIdx($cellAddressIdx, $cellData['o']); - $numberFormatType = 'n_auto'; - } else { if ($cellData['t'] === 'date') { $pattern = $this->excel->getDateFormatPattern($cellData['s']); diff --git a/tests/FastExcelTemplatorTest.php b/tests/FastExcelTemplatorTest.php index da0a08b..d055d35 100644 --- a/tests/FastExcelTemplatorTest.php +++ b/tests/FastExcelTemplatorTest.php @@ -140,7 +140,7 @@ public function test03() $this->assertEquals($c0, $c1); $c1 = $cells['C10'];unset($c1['s']); - $c0 = ['v' => '=SUM(C2:C9)', 'f' => '=SUM(C2:C9)', 'o' => '=SUM(C2:C9)', 't' => '']; + $c0 = ['v' => '=SUM(C2:C9)', 'f' => '=SUM(C2:C9)', 'o' => '=SUM(C2:C9)', 't' => 'number']; $this->assertEquals($c0, $c1); unlink($out);