I
I
Ilya2020-08-08 09:38:09
PHP
Ilya, 2020-08-08 09:38:09

Why is Phpsreadsheet creating a corrupted file?

Installed the Phpspreadsheet library on the server.
I use the test code from the documentation:

require 'vendor/autoload.php';

use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;

$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1', 'Hello World !');

$writer = new Xlsx($spreadsheet);
$writer->save('report.xlsx');

After running the script, the file is created on the server, but when I open it in MS Office (Libre Office), I get a message that the file is damaged. The restore attempt fails. The file cannot be opened.
At the same time, the CSV format works without problems.
I installed the library through Composer. There were no installation errors. The library version is 1.14. PHP version is 7.3, all necessary extensions are installed.

Has anyone encountered a similar problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dsuvorov, 2020-12-01
@dsuvorov

Same problem. Locally on OpenServer works - generates files adequately. On the combat server generates broken files.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question