Answer the question
In order to leave comments, you need to log in
Why does an error occur when opening a file created with PhpSpreadsheet?
My code for creating excel file:
header('Content-Type: application/json');
$spreadsheet = new PhpOffice\PhpSpreadsheet\Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
//формирую массив с данными
$sheet->fromArray($arrayData, NULL, 'A1');
$writer = new PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
ob_start();
$writer->save('php://output');
$xlsData = ob_get_contents();
ob_end_clean();
echo json_encode('data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,'.base64_encode($xlsData));
Answer the question
In order to leave comments, you need to log in
It happened to me too, it came out after updating Phpspreadsheet, and not in all files, but only where there were fields with lists of valid values (they pulled these values from the second sheet). Project on Laravel 5.4. I decided to downgrade the package to version 1.14 (in which it was guaranteed to work). In composer.json, forced version (without prefixes like ^ or ~)
"require": {
...
"phpoffice/phpspreadsheet": "1.14",
...
},
and ran composer update.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question