From c1d0221dcd2b4200b3ff17747e31f451fcc749f0 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Sun, 30 Jun 2024 23:35:37 +0200 Subject: [PATCH] Add path --- src/TableDocumentData.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/TableDocumentData.php b/src/TableDocumentData.php index 18998b2..dbc70f2 100644 --- a/src/TableDocumentData.php +++ b/src/TableDocumentData.php @@ -21,7 +21,7 @@ class TableDocumentData extends Data ) { } - public function compile(string $path): void + public function compile(string $path): string { $this->spreadsheet = new Spreadsheet(); $this->spreadsheet->getProperties() @@ -32,7 +32,7 @@ class TableDocumentData extends Data $this->spreadsheet->getActiveSheet()->setTitle('unfilled'); foreach ($this->sheets as $sheet) { - $this->addSheet($sheet); + $this->compileSheet($sheet); } $this->spreadsheet->setActiveSheetIndex(0); @@ -40,9 +40,18 @@ class TableDocumentData extends Data $writer = new Xlsx($this->spreadsheet); $writer->save($path); $this->spreadsheet->disconnectWorksheets(); + + return $path; } - public function addSheet(SheetData $sheet): void + public function addSheet(SheetData $sheet): self + { + $this->sheets[] = $sheet; + + return $this; + } + + private function compileSheet(SheetData $sheet): void { if ('unfilled' !== $this->spreadsheet->getActiveSheet()->getTitle()) { $this->spreadsheet->addSheet(new Worksheet($this->spreadsheet, $sheet->name));