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

Template has background image... but result doesn't have #1649

Closed
venkytt opened this issue Sep 10, 2020 · 4 comments · Fixed by #3795
Closed

Template has background image... but result doesn't have #1649

venkytt opened this issue Sep 10, 2020 · 4 comments · Fixed by #3795

Comments

@venkytt
Copy link

venkytt commented Sep 10, 2020

This is:

- [ ] 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?

What is the current behavior?

What are the steps to reproduce?

I have an .xlsx file created in microsoft excel. this has a backround image. I use this file as a template. All other formatting is preserved but the background image is not visible when I create the output file based on this template

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';

// Create new Spreadsheet object
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
$spreadsheet = $reader->load($inputFile);


						$sheet = $spreadsheet->getSheetByName('MainSheet');
						$sheet->setCellValue('a2', $excelTitle);
						if ($userPic) { //try getting it again just in case settings changed later 
								$drawing = new \PhpOffice\PhpSpreadsheet\Worksheet\Drawing();
								$drawing->setPath($userPic); // put your path and image here
								$drawing->setCoordinates('B2');
								$drawing->setWidthAndHeight(280, 280);
								$drawing->setOffsetX(28);
								$drawing->setRotation(0);
								$drawing->getShadow()->setVisible(true);
								$drawing->getShadow()->setDirection(45);
								$drawing->setWorksheet($spreadsheet->getActiveSheet());				
						}

    $writer = new Xlsx($spreadsheet);
						echo "\r\n\r\n writing to $outputFile line " . __LINE__ ;
    $writer->save($outputFile);
// add code that show the issue here...

Which versions of PhpSpreadsheet and PHP are affected?

1.14.1 - 2020-07-19
PHP Version 7.2.24

@Raemy92
Copy link

Raemy92 commented Sep 11, 2020

Maybe this could be related to #1645 ?

@venkytt
Copy link
Author

venkytt commented Sep 12, 2020

Maybe this could be related to #1645 ?

Perhaps.. but only if the same code of the library handles the image present in the 'template' file as well, but I doubt it

@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 added a commit to oleibman/PhpSpreadsheet that referenced this issue Nov 19, 2023
Fix PHPOffice#1649, a 3-year-old issue long marked "stale". Excel supports background images on sheets; now PhpSpreadsheet will as well. Support is limited to Xlsx (read and write) and Html (write only). As far as I can tell, Excel Xml and Gnumeric do not support this, nor, of course, do Csv and Slk; Excel Xls does, but, as usual, how to handle it in BIFF format is a mystery; LibreOffice ODS supports it differently than Excel, and this is just another of many ODS style properties not currently supported by PhpSpreadsheet.
@oleibman oleibman mentioned this issue Nov 19, 2023
11 tasks
@oleibman
Copy link
Collaborator

Removing stale label.

@stale stale bot removed the stale label Nov 19, 2023
oleibman added a commit that referenced this issue Nov 21, 2023
* Sheet Background Images

Fix #1649, a 3-year-old issue long marked "stale". Excel supports background images on sheets; now PhpSpreadsheet will as well. Support is limited to Xlsx (read and write) and Html (write only). As far as I can tell, Excel Xml and Gnumeric do not support this, nor, of course, do Csv and Slk; Excel Xls does, but, as usual, how to handle it in BIFF format is a mystery; LibreOffice ODS supports it differently than Excel, and this is just another of many ODS style properties not currently supported by PhpSpreadsheet.

* Update CHANGELOG.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants