<?php

use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Ods;

use Psr\Http\Message\ResponseInterface;

class Controller
{
    public function exportAction(): ResponseInterface
    {
        $spreadsheet = new Spreadsheet();
        $activeWorksheet = $spreadsheet->getActiveSheet();
        $activeWorksheet->setCellValue('A1', 'Hello World !');

        $writer = new Ods($spreadsheet);

        return $this->responseFactory->createResponse()
            ->withHeader('Content-Type', 'application/vnd.oasis.opendocument.spreadsheet')
            ->withBody(new SpreadsheetStream($writer));
    }

}