P
P
Pavel Gogolinsky2018-08-04 01:03:19
PHP
Pavel Gogolinsky, 2018-08-04 01:03:19

How to solve error after file creation via phpspreadsheet?

Has anyone encountered such an error? I create a file according to a template (according to this documentation phpspreadsheet.readthedocs.io/en/develop/topics/re...

$reader = IOFactory::createReaderForFile($file);
        $spreadsheet = $reader->load($file);
        $cells = $spreadsheet->getActiveSheet()->getCellCollection();

        foreach ($positions as $position) {
            $cells->get('A' . $position['id'])->setValue($position['sum']);
        }

        $writer = IOFactory::createWriter($spreadsheet, ucfirst(pathinfo($file, PATHINFO_EXTENSION)));
        $fileName = time() . '.' . pathinfo($file, PATHINFO_EXTENSION);
        $writer->save("./$fileName");

After saving, I try to open a new file - I get the error "The file is corrupted.". If you show the recovery logs, it says there
<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><logFileName>Поместить результат восстановления в zavyalov_10_15333315530.xml</logFileName><summary>Обнаружены ошибки в файле \"/Users/paul/Downloads/zavyalov_10_1533331553.xlsx\"</summary><removedParts summary="Ниже приведен список удаленных компонентов:"><removedPart>Удаленный компонент: Рисованная фигура.</removedPart></removedParts></recoveryLog>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question