Skip to content

Drawings get lost addExternalSheet #1294

Closed
@CiTRO33

Description

This is:

- [x] a bug report

What is the expected behavior?

two xlsx-template files with one sheet and a image should combined into one xlsx with two sheets.

What is the current behavior?

xlsx-files gets combined and corrupted, recovered xlsx removes the image on second sheet.

maybe its the same cause: see #1140, #927, #1022 #877 (comment)

What are the steps to reproduce?

Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:

<?php

require __DIR__ . '/vendor/autoload.php';

$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx ();
$spfirst = $reader->load ( "first.xlsx" );
$spsecond = $reader->load ( "second.xlsx" );
$pSheet = $spsecond->getActiveSheet ();
$spfirst->addExternalSheet ( $pSheet, 0 );

$objWriter = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx ( $spfirst );
$objWriter->setPreCalculateFormulas ( true );

$objWriter->save ( "result.xlsx" );


Example files:

[first.xlsx](https://github.com/PHPOffice/PhpSpreadsheet/files/3991477/first.xlsx)
[second.xlsx](https://github.com/PHPOffice/PhpSpreadsheet/files/3991479/second.xlsx)

[result.xlsx](https://github.com/PHPOffice/PhpSpreadsheet/files/3991478/result.xlsx)

### Which versions of PhpSpreadsheet and PHP are affected?

1.10.1 / 1.8.2

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