Skip to content

Commit

Permalink
Corrupt Sample Output for 20 and 30 (#2648)
Browse files Browse the repository at this point in the history
Xls Reader can read drawing offsetX and offsetY as float. However, Excel Xlsx (and PhpSpreadsheet) wants them only as int. This leads 20_Read_Xls and 30_Template to produce corrupt Xlsx files for any Php release. Change Xls Reader to treat values as int, eliminating the corrupt files.
  • Loading branch information
oleibman authored Mar 4, 2022
1 parent e87be5e commit dade9cc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/PhpSpreadsheet/Reader/Xls.php
Original file line number Diff line number Diff line change
Expand Up @@ -1101,8 +1101,8 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet
$height = SharedXls::getDistanceY($this->phpSheet, $startRow, $startOffsetY, $endRow, $endOffsetY);

// calculate offsetX and offsetY of the shape
$offsetX = $startOffsetX * SharedXls::sizeCol($this->phpSheet, $startColumn) / 1024;
$offsetY = $startOffsetY * SharedXls::sizeRow($this->phpSheet, $startRow) / 256;
$offsetX = (int) ($startOffsetX * SharedXls::sizeCol($this->phpSheet, $startColumn) / 1024);
$offsetY = (int) ($startOffsetY * SharedXls::sizeRow($this->phpSheet, $startRow) / 256);

switch ($obj['otObjType']) {
case 0x19:
Expand Down

0 comments on commit dade9cc

Please sign in to comment.