0
<?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

enter image description here

  • write new file

enter image description here

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?

jongba
  • 1
  • 1

1 Answers1

0

PHPSpreadsheet writes not in the original file. It produce a copy. Some excel features are not supported and will not show in the new file.

  • Additional info: when you write to a new file, external images like your inserted png, jpeg, etc is supported. – Zeikman Feb 07 '23 at 07:47