Skip to content

CRASH load,save,load,save=Crash if images in footer #3126

Closed
@alaindev

Description

@alaindev

This is:

Hello

PHPSpreadsheet CRASHes when 2 consuccessif load->Save if images are in headerFooterImages

I have an Excel-1 file as a template

load Excel-1=>save to Excel-2

load Excel-2 =>save to Excel-Final = CRASH since footer image is no longer found in zip!


### What is the expected behavior?
No Exception

### What is the current behavior?
ThrowException in 

### What are the steps to reproduce?

Please provide a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) of code that exhibits the issue without relying on an external Excel file or a web server:

<?php

require 'includes/modules/autoload.php';

// Create new Spreadsheet object
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load("DEBUG.xlsx");
			$filewriter = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet , "Xlsx");
			$filewriter->setIncludeCharts(true);
			$filewriter->save("EXCEL2.xlsx");

$spread2sheet = \PhpOffice\PhpSpreadsheet\IOFactory::load("EXCEL2.xlsx");
			$filewriter2 = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spread2sheet , "Xlsx");
			$filewriter2->setIncludeCharts(true);
			$filewriter2->save("EXCELFINAL.xlsx"); // => CRASH if image in Footer

exit();
?>

### What features do you think are causing the issue

- [ ] Reader
- [ X] Writer
- [ ] Styles
- [ ] Data Validations
- [ ] Formula Calculations
- [ ] Charts
- [ ] AutoFilter
- [ ] Form Elements

### Does an issue affect all spreadsheet file formats? If not, which formats are affected?

xlsx

### Which versions of PhpSpreadsheet and PHP are affected?
All
[DEBUG.xlsx](https://github.com/PHPOffice/PhpSpreadsheet/files/9802175/DEBUG.xlsx)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions