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

Missing header image when opening an excel file an saving it #1645

Closed
Raemy92 opened this issue Sep 9, 2020 · 3 comments
Closed

Missing header image when opening an excel file an saving it #1645

Raemy92 opened this issue Sep 9, 2020 · 3 comments

Comments

@Raemy92
Copy link

Raemy92 commented Sep 9, 2020

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)

I'm using this library on a TYPO3 installation to create excel order sheets from some articles. Everything works like a charm but the image in the header disappears.

I'm using a tamplate .xlsx file with the headers (image and some text) included, insert the articles with this library and save it to another path.

When I'm opening the file the header text and the articles are correctly saved but no the header image.

What is the expected behavior?

The same header as in the template file (image and text)

What is the current behavior?

Only the header text appears. The image on the header left is missing.

What are the steps to reproduce?

  1. Load the Excel template
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($this->pathToTemplate);
  1. Make some changes (in my case add the articles). I used a loop with something similar to this:
$spreadsheet->getActiveSheet()->setCellValue($cell, $text);
  1. Save the File in another path because the template is used multiple times
$writer = new Xlsx($spreadsheet);
$writer->save($savePath);

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:

See code above.

I also tried to insert the image manually:

$drawing = new HeaderFooterDrawing();
$drawing->setName('Logo');
$drawing->setPath($pathToImage);
$drawing->setHeight(90);
$spreadsheet->getActiveSheet()->getHeaderFooter()->addImage($drawing, \PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooter::IMAGE_HEADER_LEFT);

Which versions of PhpSpreadsheet and PHP are affected?

PHPSpreadSheet: 1.14
PHP: 7.2

@k7y6t5
Copy link

k7y6t5 commented Oct 16, 2020

@Raemy92 I haven't tried working with a template that already contains a header image but I have tried to insert one manually. It's not working for me either.

https://phpspreadsheet.readthedocs.io/en/latest/topics/recipes/#setting-the-print-header-and-footer-of-a-worksheet

PHPSpreadsheet 1.8
PHP 7.4.9

@stale
Copy link

stale bot commented Dec 25, 2020

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.

@stale stale bot added the stale label Dec 25, 2020
@oleibman
Copy link
Collaborator

Closing. I believe this issue is resolved. For example, if I load tests/data/Reader/XLSX/issue.3126.xlsx and save it elsewhere, the output file contains the same footer image as the input file. The same is true when I add a header image as well.

@oleibman oleibman removed the stale label Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants