diff --git a/app/Modules/Group/Actions/SubgroupMembersMakeExcel.php b/app/Modules/Group/Actions/SubgroupMembersMakeExcel.php index 3f265fccf..7efaa3d6a 100644 --- a/app/Modules/Group/Actions/SubgroupMembersMakeExcel.php +++ b/app/Modules/Group/Actions/SubgroupMembersMakeExcel.php @@ -4,13 +4,14 @@ use Carbon\Carbon; use App\Modules\Group\Models\Group; use Lorisleiva\Actions\ActionRequest; -use Box\Spout\Common\Entity\Style\Color; +use OpenSpout\Common\Entity\Row; use App\Modules\Group\Models\GroupMember; -use Box\Spout\Common\Entity\Style\Border; +use OpenSpout\Common\Entity\Style\Border; +use OpenSpout\Common\Entity\Style\BorderPart; +use OpenSpout\Common\Entity\Style\Color; +use OpenSpout\Common\Entity\Style\Style; use Lorisleiva\Actions\Concerns\AsController; -use Box\Spout\Writer\Common\Creator\Style\StyleBuilder; -use Box\Spout\Writer\Common\Creator\Style\BorderBuilder; -use Box\Spout\Writer\Common\Creator\WriterEntityFactory; +use OpenSpout\Writer\XLSX\Writer; class SubgroupMembersMakeExcel { use AsController; @@ -47,7 +48,7 @@ private function writeAllSheet($writer, $group) $byPersonThenGroup = $allMemberships->groupBy(['person_id', 'group_id']); // The 'Any active?' column is included to allow for easy filtering in Excel, but it redundant to whether the 'Active Memberships' column is empty or not. - $headerRow = WriterEntityFactory::createRowFromArray( + $headerRow = Row::fromValues( ['Name', 'Email', 'Institution', 'Active Memberships', 'Retired Memberships', 'Any active?'], $this->getHeaderStyle() ); @@ -77,14 +78,14 @@ private function writeAllSheet($writer, $group) $active = collect($active)->unique()->values(); $retired = collect($retired)->unique()->values(); - return WriterEntityFactory::createRowFromArray([ + return Row::fromValues([ $person->name, $person->email, ($person->institution) ? $person->institution?->name : null, $active->join(', '), $retired->join(', '), $active->isEmpty() ? 'No' : 'Yes', - ], (new StyleBuilder())->setShouldWrapText(false)->build()); + ], (new Style())->setShouldWrapText(false)); })->all(); $writer->addRows($rows); @@ -100,23 +101,23 @@ private function writeGroupSheet($writer, $group) { $headerRow = $this->getGroupHeaderRow(); - $noWrapStyle = (new StyleBuilder())->setShouldWrapText(false)->build(); + $noWrapStyle = (new Style())->setShouldWrapText(false); $memberRows = $group->members->map(function ($member) use ($noWrapStyle) { $row = $this->getGroupMemberRow($member); $row->setStyle($noWrapStyle); return $row; }); - $writer - ->addRow(WriterEntityFactory::createRowFromArray([$group->name])) - ->addRow(WriterEntityFactory::createRowFromArray([])) - ->addRow($headerRow, $this->getHeaderStyle()) - ->addRows($memberRows->toArray()); + + $writer->addRow(Row::fromValues([$group->name])); + $writer->addRow(Row::fromValues([])); + $writer->addRow($headerRow); + $writer->addRows($memberRows->toArray()); } private function getGroupMemberRow(GroupMember $member) { - return WriterEntityFactory::createRowFromArray($this->truncateValues([ + return Row::fromValues($this->truncateValues([ $member->person->first_name, $member->person->last_name, $member->person->email, @@ -156,7 +157,7 @@ private function truncateValues(Array $array, int $max = 10000): array private function getGroupHeaderRow() { - return WriterEntityFactory::createRowFromArray([ + return Row::fromValues([ 'first_name', 'last_name', 'email', @@ -187,20 +188,19 @@ private function makeFileName(Group $group) private function getXLSXWriter($fileName) { - $writer = WriterEntityFactory::createXLSXWriter(); + $writer = new Writer(); $writer->openToFile($fileName); return $writer; } private function getHeaderStyle() { - $border = (new BorderBuilder())->setBorderBottom(Color::BLACK, Border::WIDTH_THIN)->build(); + $border = new Border(new BorderPart(Border::BOTTOM, Color::BLACK, Border::WIDTH_THIN)); - return (new StyleBuilder()) + return (new Style()) ->setFontBold() ->setFontSize(14) - ->setBorder($border) - ->build(); + ->setBorder($border); } diff --git a/composer.json b/composer.json index b63ce2ab6..cacb69f25 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "license": "MIT", "require": { "php": "^8.2", - "box/spout": "^3.3", + "openspout/openspout": "^4.0", "doctrine/dbal": "^3.1", "dompdf/dompdf": "^2.0", "guzzlehttp/guzzle": "^7.5", diff --git a/composer.lock b/composer.lock index a2ce568b5..a28c1bb00 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f745ba69a819089215ff25ed2e002cc1", + "content-hash": "d4302954eb4950e6af143295590b62ea", "packages": [ { "name": "bacon/bacon-qr-code", @@ -61,81 +61,6 @@ }, "time": "2025-11-19T17:15:36+00:00" }, - { - "name": "box/spout", - "version": "v3.3.0", - "source": { - "type": "git", - "url": "https://github.com/box/spout.git", - "reference": "9bdb027d312b732515b884a341c0ad70372c6295" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/box/spout/zipball/9bdb027d312b732515b884a341c0ad70372c6295", - "reference": "9bdb027d312b732515b884a341c0ad70372c6295", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-xmlreader": "*", - "ext-zip": "*", - "php": ">=7.2.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^2", - "phpunit/phpunit": "^8" - }, - "suggest": { - "ext-iconv": "To handle non UTF-8 CSV files (if \"php-intl\" is not already installed or is too limited)", - "ext-intl": "To handle non UTF-8 CSV files (if \"iconv\" is not already installed)" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Box\\Spout\\": "src/Spout" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "Adrien Loison", - "email": "adrien@box.com" - } - ], - "description": "PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way", - "homepage": "https://www.github.com/box/spout", - "keywords": [ - "OOXML", - "csv", - "excel", - "memory", - "odf", - "ods", - "office", - "open", - "php", - "read", - "scale", - "spreadsheet", - "stream", - "write", - "xlsx" - ], - "support": { - "issues": "https://github.com/box/spout/issues", - "source": "https://github.com/box/spout/tree/v3.3.0" - }, - "abandoned": true, - "time": "2021-05-14T21:18:09+00:00" - }, { "name": "brick/math", "version": "0.14.1", @@ -3652,6 +3577,99 @@ ], "time": "2025-11-20T02:34:59+00:00" }, + { + "name": "openspout/openspout", + "version": "v4.32.0", + "source": { + "type": "git", + "url": "https://github.com/openspout/openspout.git", + "reference": "41f045c1f632e1474e15d4c7bc3abcb4a153563d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/openspout/openspout/zipball/41f045c1f632e1474e15d4c7bc3abcb4a153563d", + "reference": "41f045c1f632e1474e15d4c7bc3abcb4a153563d", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-fileinfo": "*", + "ext-filter": "*", + "ext-libxml": "*", + "ext-xmlreader": "*", + "ext-zip": "*", + "php": "~8.3.0 || ~8.4.0 || ~8.5.0" + }, + "require-dev": { + "ext-zlib": "*", + "friendsofphp/php-cs-fixer": "^3.86.0", + "infection/infection": "^0.31.2", + "phpbench/phpbench": "^1.4.1", + "phpstan/phpstan": "^2.1.22", + "phpstan/phpstan-phpunit": "^2.0.7", + "phpstan/phpstan-strict-rules": "^2.0.6", + "phpunit/phpunit": "^12.3.7" + }, + "suggest": { + "ext-iconv": "To handle non UTF-8 CSV files (if \"php-mbstring\" is not already installed or is too limited)", + "ext-mbstring": "To handle non UTF-8 CSV files (if \"iconv\" is not already installed)" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.3.x-dev" + } + }, + "autoload": { + "psr-4": { + "OpenSpout\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Adrien Loison", + "email": "adrien@box.com" + } + ], + "description": "PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way", + "homepage": "https://github.com/openspout/openspout", + "keywords": [ + "OOXML", + "csv", + "excel", + "memory", + "odf", + "ods", + "office", + "open", + "php", + "read", + "scale", + "spreadsheet", + "stream", + "write", + "xlsx" + ], + "support": { + "issues": "https://github.com/openspout/openspout/issues", + "source": "https://github.com/openspout/openspout/tree/v4.32.0" + }, + "funding": [ + { + "url": "https://paypal.me/filippotessarotto", + "type": "custom" + }, + { + "url": "https://github.com/Slamdunk", + "type": "github" + } + ], + "time": "2025-09-03T16:03:54+00:00" + }, { "name": "paragonie/constant_time_encoding", "version": "v3.1.3",