Skip to content

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

@venkytt

Description

@venkytt

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

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