Skip to content

Commit 2848e38

Browse files
committed
fix(app): fix update version
1 parent 67434d4 commit 2848e38

4 files changed

Lines changed: 16 additions & 7 deletions

File tree

src/Services/Export/Exporter.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Doctrine\ORM\PersistentCollection;
1010
use Doctrine\ORM\Query;
1111
use InvalidArgumentException;
12+
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
1213
use PhpOffice\PhpSpreadsheet\Spreadsheet;
1314
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
1415
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
@@ -125,7 +126,8 @@ private function getTranslatedHeaders(array $methods): array
125126
private function writeHeadersToSheet(Worksheet $sheet, array $headers): void
126127
{
127128
foreach ($headers as $col => $header) {
128-
$sheet->setCellValueByColumnAndRow($col + 1, 1, $header);
129+
$cell = Coordinate::stringFromColumnIndex($col + 1) . '1';
130+
$sheet->setCellValue($cell, $header);
129131
}
130132
}
131133

@@ -136,7 +138,8 @@ private function writeValuesToSheet(Worksheet $sheet, array $values): void
136138
{
137139
foreach ($values as $row => $value) {
138140
foreach ($value as $col => $val) {
139-
$sheet->setCellValueByColumnAndRow($col + 1, $row + 2, $val);
141+
$cell = Coordinate::stringFromColumnIndex($col + 1) . ($row + 2);
142+
$sheet->setCellValue($cell, $val);
140143
}
141144
}
142145
}

src/Services/Import/ImporterTemplate.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace SymfonyImportExportBundle\Services\Import;
66

77
use InvalidArgumentException;
8+
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
89
use PhpOffice\PhpSpreadsheet\Spreadsheet;
910
use PhpOffice\PhpSpreadsheet\Writer\Xlsx as XlsxWriter;
1011
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
@@ -72,7 +73,8 @@ private function getXlsxTemplate(array $fields): StreamedResponse
7273

7374
foreach ($fields as $col => $field) {
7475
$translatedField = $this->getTranslatedField($field);
75-
$sheet->setCellValueByColumnAndRow($col + 1, 1, '' === $translatedField ? $field : $translatedField);
76+
$cell = Coordinate::stringFromColumnIndex($col + 1) . '1';
77+
$sheet->setCellValue($cell, '' === $translatedField ? $field : $translatedField);
7678
}
7779

7880
$response = new StreamedResponse(function () use ($spreadsheet) {

tests/Services/Export/ExporterTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
use function sys_get_temp_dir;
1414
use function tempnam;
1515
use function unlink;
16+
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
1617
use PhpOffice\PhpSpreadsheet\IOFactory;
1718
use PhpOffice\PhpSpreadsheet\Spreadsheet;
18-
use PHPUnit\Framework\TestCase;
1919

20+
use PHPUnit\Framework\TestCase;
2021
use Symfony\Component\HttpFoundation\StreamedResponse;
2122
use Symfony\Contracts\Translation\TranslatorInterface;
2223
use SymfonyImportExportBundle\Services\Export\Exporter;
@@ -67,7 +68,8 @@ public function testExportToXlsxGeneratesCorrectResponse(): void
6768

6869
foreach ($methods as $col => $method) {
6970
$expectedHeader = 'import_export.' . $this->methodToSnake->convert($method);
70-
$this->assertEquals($expectedHeader, $sheet->getCellByColumnAndRow($col + 1, 1)->getValue());
71+
$cell = Coordinate::stringFromColumnIndex($col + 1) . '1';
72+
$this->assertEquals($expectedHeader, $sheet->getCell($cell)->getValue());
7173
}
7274

7375
$this->assertEquals(1, $sheet->getCell('A2')->getValue());

tests/Services/Import/ImportTemplateGeneratorTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
use function sys_get_temp_dir;
1212
use function tempnam;
1313
use function unlink;
14-
use PhpOffice\PhpSpreadsheet\IOFactory;
14+
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
1515

16+
use PhpOffice\PhpSpreadsheet\IOFactory;
1617
use PhpOffice\PhpSpreadsheet\Spreadsheet;
1718
use PHPUnit\Framework\TestCase;
1819
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
@@ -64,7 +65,8 @@ public function testGetImportTemplateXlsx(): void
6465

6566
$expectedHeaders = ['id', 'name', 'email', 'created_at'];
6667
foreach ($expectedHeaders as $col => $header) {
67-
$this->assertEquals($header, $sheet->getCellByColumnAndRow($col + 1, 1)->getValue());
68+
$cell = Coordinate::stringFromColumnIndex($col + 1) . '1';
69+
$this->assertEquals($header, $sheet->getCell($cell)->getValue());
6870
}
6971

7072
unlink($tempFilePath);

0 commit comments

Comments
 (0)