mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Refactor export method to use FormattedExportGeneration.
Replaces direct BinaryFileResponse usage with FormattedExportGeneration for handling file exports. Removes unnecessary imports and ensures temporary file cleanup after processing.
This commit is contained in:
parent
e37f3e7c37
commit
50c75dff1a
@ -21,8 +21,6 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|||||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
|
||||||
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
|
|
||||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
@ -120,11 +118,10 @@ class ListPersonDuplicate implements DirectExportInterface, ExportElementValidat
|
|||||||
$temp_file = sys_get_temp_dir().'/'.uniqid('export_').'.xlsx';
|
$temp_file = sys_get_temp_dir().'/'.uniqid('export_').'.xlsx';
|
||||||
$writer->save($temp_file);
|
$writer->save($temp_file);
|
||||||
|
|
||||||
$response = new BinaryFileResponse($temp_file);
|
$formatted = new FormattedExportGeneration(file_get_contents($temp_file), 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||||||
$response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
unlink($temp_file);
|
||||||
$response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, 'export_duplicate.xlsx');
|
|
||||||
|
|
||||||
return $response;
|
return $formatted;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDescription(): string
|
public function getDescription(): string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user