Check array key exists before access in Xlsx.php (#1970)
When loading an xlsx file which has images that use a URL, there's a PHP Notice that is shown. Added a check for the existence of the array key for accessing.
This commit is contained in:
parent
edca1f573d
commit
818b993f2e
|
|
@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
|||
|
||||
### Fixed
|
||||
|
||||
- Fixed issue where array key check for existince before accessing arrays in Xlsx.php. [PR #1970](https://github.com/PHPOffice/PhpSpreadsheet/pull/1970)
|
||||
- Fixed issue with quoted strings in number format mask rendered with toFormattedString() [Issue 1972#](https://github.com/PHPOffice/PhpSpreadsheet/issues/1972) [PR #1978](https://github.com/PHPOffice/PhpSpreadsheet/pull/1978)
|
||||
- Fixed issue with percentage formats in number format mask rendered with toFormattedString() [Issue 1929#](https://github.com/PHPOffice/PhpSpreadsheet/issues/1929) [PR #1928](https://github.com/PHPOffice/PhpSpreadsheet/pull/1928)
|
||||
- Fixed issue with _ spacing character in number format mask corrupting output from toFormattedString() [Issue 1924#](https://github.com/PHPOffice/PhpSpreadsheet/issues/1924) [PR #1927](https://github.com/PHPOffice/PhpSpreadsheet/pull/1927)
|
||||
|
|
|
|||
|
|
@ -1134,15 +1134,20 @@ class Xlsx extends BaseReader
|
|||
$objDrawing = new \PhpOffice\PhpSpreadsheet\Worksheet\Drawing();
|
||||
$objDrawing->setName((string) self::getArrayItem($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(), 'name'));
|
||||
$objDrawing->setDescription((string) self::getArrayItem($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(), 'descr'));
|
||||
$objDrawing->setPath(
|
||||
'zip://' . File::realpath($pFilename) . '#' .
|
||||
$images[(string) self::getArrayItem(
|
||||
$imageKey = (string) self::getArrayItem(
|
||||
$blip->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'),
|
||||
'embed'
|
||||
)],
|
||||
);
|
||||
|
||||
if (isset($images[$imageKey])) {
|
||||
$objDrawing->setPath(
|
||||
'zip://' . File::realpath($pFilename) . '#' .
|
||||
$images[$imageKey],
|
||||
false
|
||||
);
|
||||
}
|
||||
$objDrawing->setCoordinates(Coordinate::stringFromColumnIndex(((int) $oneCellAnchor->from->col) + 1) . ($oneCellAnchor->from->row + 1));
|
||||
|
||||
$objDrawing->setOffsetX(Drawing::EMUToPixels($oneCellAnchor->from->colOff));
|
||||
$objDrawing->setOffsetY(Drawing::EMUToPixels($oneCellAnchor->from->rowOff));
|
||||
$objDrawing->setResizeProportional(false);
|
||||
|
|
@ -1200,15 +1205,19 @@ class Xlsx extends BaseReader
|
|||
$objDrawing = new \PhpOffice\PhpSpreadsheet\Worksheet\Drawing();
|
||||
$objDrawing->setName((string) self::getArrayItem($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(), 'name'));
|
||||
$objDrawing->setDescription((string) self::getArrayItem($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(), 'descr'));
|
||||
$objDrawing->setPath(
|
||||
'zip://' . File::realpath($pFilename) . '#' .
|
||||
$images[(string) self::getArrayItem(
|
||||
$imageKey = (string) self::getArrayItem(
|
||||
$blip->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'),
|
||||
'embed'
|
||||
)],
|
||||
);
|
||||
if (isset($images[$imageKey])) {
|
||||
$objDrawing->setPath(
|
||||
'zip://' . File::realpath($pFilename) . '#' .
|
||||
$images[$imageKey],
|
||||
false
|
||||
);
|
||||
}
|
||||
$objDrawing->setCoordinates(Coordinate::stringFromColumnIndex(((int) $twoCellAnchor->from->col) + 1) . ($twoCellAnchor->from->row + 1));
|
||||
|
||||
$objDrawing->setOffsetX(Drawing::EMUToPixels($twoCellAnchor->from->colOff));
|
||||
$objDrawing->setOffsetY(Drawing::EMUToPixels($twoCellAnchor->from->rowOff));
|
||||
$objDrawing->setResizeProportional(false);
|
||||
|
|
|
|||
Loading…
Reference in New Issue