Skip to content

Commit

Permalink
Merge pull request #2411 from skaut/2410-phpofficephpspreadsheetexcep…
Browse files Browse the repository at this point in the history
…tion-maximum-31-characters-allowed-in-sheet-title

The sheet title in Excel can only have 31 characters
  • Loading branch information
juradee authored Oct 24, 2023
2 parents 1e7615a + 40c5c26 commit 920fd2a
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@
use Model\UnitService;
use Nette\Utils\Strings;
use PhpOffice\PhpSpreadsheet\Exception;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
use Skautis\Wsdl\PermissionException;

use function array_filter;
use function assert;
use function count;
use function date;
use function sprintf;
use function substr;

class PaymentPresenter extends BasePresenter
{
Expand Down Expand Up @@ -277,11 +279,12 @@ public function handleExport(int $id): void
{
$this->assertCanEditGroup();

$group = $this->model->getGroup($id);
$payments = $this->getPaymentsForGroup($id);
$group = $this->model->getGroup($id);
$payments = $this->getPaymentsForGroup($id);
$groupName = substr($group->getName(), 0, Worksheet::SHEET_TITLE_MAXIMUM_LENGTH);

try {
$spreadsheet = $this->excelService->getPaymentsList($payments, $group->getName());
$spreadsheet = $this->excelService->getPaymentsList($payments, $groupName);
$this->flashMessage('Seznam plateb byl exportován');
$this->sendResponse(new ExcelResponse(Strings::webalize($group->getName()) . '-' . date('Y_n_j'), $spreadsheet));
} catch (PermissionException $e) {
Expand Down

0 comments on commit 920fd2a

Please sign in to comment.