PhpSpreadsheet
PhpSpreadsheet copied to clipboard
The problem that the shape and image of a specific sheet disappear when saving a file
<?php
require __DIR__ . '/vendor/autoload.php';
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
$spreadsheet = $reader->load($origin_file);
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
$writer->setPreCalculateFormulas(false);
$writer->setOffice2003Compatibility(true);
$new_file = './file_uploads/report_file/' . $file_info_idx.'_tmp.'.$file_ext;
$writer->save($new_file);
- original file

- write new file

As above, if you save a picture or image of a specific sheet in the original file as a new file, the picture or image will be lost. ex) sheet2
Is there something I'm missing out on?
Please upload the original file.
For security reasons, we will remove all contents.
Please check the parts where figures and images are missing.
Thank you for the file. I can confirm your problem. The images that are missing all seem to be "shapes" rather than "drawings", but not all shapes are missing (e.g. on sheet 2). I don't know anything about shape files, except that they have been involved in other issues. It could take a while to figure out what is happening, and what should be happening instead.
Only certain shapes are kept and the rest of the shapes are lost. What code should I write to keep it?
I don't think the problem is in your code. I think the problem can be solved only by better handling of shape files by PhpSpreadsheet, which I think will not be a quick or easy change.
Correct; shape files aren't supported at all by PhpSpreadsheet; we'd have to build that support from the basics upwards
So what should we do?
please tell me how
You live with it until we can implement it; or work out how to implement it yourself and submit a PR
@MarkBaker is there any solution for this problem, i also experienced it, my shape is missing
drawing or shape is removed ☹️
edit i fixed it by ungrouping everything in the worksheet