Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logo in header cause Undefined index: height #888

Closed
lodzen opened this issue Feb 15, 2019 · 1 comment
Closed

Logo in header cause Undefined index: height #888

lodzen opened this issue Feb 15, 2019 · 1 comment
Labels

Comments

@lodzen
Copy link

lodzen commented Feb 15, 2019

This is:

- [ x] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

The loader should read Images in Header.

What is the current behavior?

The method $reader->load($pFilename); is throwing an Undefined index: height exception

in phpspreadsheet\src\PhpSpreadsheet\Reader\Xlsx.php[Line 1569]:

                                                $hfImages[(string) $shape['id']] = new HeaderFooterDrawing();
                                                if (isset($imageData['title'])) {
                                                    $hfImages[(string) $shape['id']]->setName((string) $imageData['title']);
                                                }
 
                                                $hfImages[(string) $shape['id']]->setPath('zip://' . File::realpath($pFilename) . '#' . $drawings[(string) $imageData['relid']], false);
                                                $hfImages[(string) $shape['id']]->setResizeProportional(false);
                                                $hfImages[(string) $shape['id']]->setWidth($style['width']);
 **--> This line cause the issue**                   $hfImages[(string) $shape['id']]->setHeight($style['height']);
                                                if (isset($style['margin-left'])) {
                                                    $hfImages[(string) $shape['id']]->setOffsetX($style['margin-left']);
                                                }
                                                $hfImages[(string) $shape['id']]->setOffsetY($style['margin-top']);
                                                $hfImages[(string) $shape['id']]->setResizeProportional(true);

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:

Create an empty excel sheet with a logo in the header.

<?php

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

// Create new Spreadsheet object
        $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load("test.xlsx");     
        $sheet = $spreadsheet->getSheetByName('Description');
        $sheet->setCellValue('F5', 'Test');

        $writer = new Xlsx($spreadsheet);
        $writer->save('intermediate.xlsx');

Which versions of PhpSpreadsheet and PHP are affected?

1.6

@stale
Copy link

stale bot commented Apr 16, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this is still an issue for you, please try to help by debugging it further and sharing your results.
Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant