Skip to content

Commit 8f7baa4

Browse files
committed
replaces deprecated box/spout with maintained openspout/openspout
1 parent b79848c commit 8f7baa4

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
}
1919
],
2020
"require": {
21-
"box/spout": "^3.0",
2221
"laravel-enso/core": "^10.0",
22+
"openspout/openspout": "^4.0",
2323
"laravel-enso/enums": "^2.0",
2424
"laravel-enso/helpers": "^3.0",
2525
"laravel-enso/io": "^2.0",

src/Contracts/CustomRowAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace LaravelEnso\DataExport\Contracts;
44

5-
use Box\Spout\Writer\XLSX\Writer;
5+
use OpenSpout\Writer\XLSX\Writer;
66

77
interface CustomRowAction
88
{

src/Services/ExcelExport.php

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
namespace LaravelEnso\DataExport\Services;
44

5-
use Box\Spout\Common\Entity\Row;
6-
use Box\Spout\Writer\Common\Creator\Style\StyleBuilder;
7-
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
8-
use Box\Spout\Writer\XLSX\Writer;
95
use Illuminate\Support\Collection;
106
use Illuminate\Support\Facades\Config;
117
use Illuminate\Support\Facades\Storage;
@@ -22,6 +18,8 @@
2218
use LaravelEnso\Files\Models\File;
2319
use LaravelEnso\Files\Models\Type;
2420
use LaravelEnso\Helpers\Services\OptimalChunk;
21+
use OpenSpout\Common\Entity\Row;
22+
use OpenSpout\Writer\XLSX\Writer;
2523
use Throwable;
2624

2725
class ExcelExport
@@ -82,14 +80,9 @@ private function before(): self
8280

8381
private function initWriter(): self
8482
{
85-
$this->writer = WriterEntityFactory::createXLSXWriter();
83+
$this->writer = new Writer();
8684

87-
$defaultStyle = (new StyleBuilder())
88-
->setShouldWrapText(false)
89-
->build();
90-
91-
$this->writer->setDefaultRowStyle($defaultStyle)
92-
->openToFile(Storage::path($this->path()));
85+
$this->writer->openToFile(Storage::path($this->path()));
9386

9487
return $this;
9588
}
@@ -153,9 +146,9 @@ private function addRow($row)
153146
$this->currentSheet++;
154147
}
155148

156-
private function row($row): Row
149+
private function row(array $row): Row
157150
{
158-
return WriterEntityFactory::createRowFromArray($row);
151+
return new Row($row);
159152
}
160153

161154
private function addSheet(): void

0 commit comments

Comments
 (0)