| Conditions | 1 |
| Paths | 1 |
| Total Lines | 14 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | private function readSpreadsheet(string $filename): Spreadsheet |
||
| 16 | { |
||
| 17 | // Assert that it is a valid ZIP file to prevent PhpSpreadsheet from hanging |
||
| 18 | $zip = new ZipArchive(); |
||
| 19 | $res = $zip->open($filename, ZipArchive::CHECKCONS); |
||
| 20 | self::assertTrue($res, 'exported Excel should be a valid ZIP file'); |
||
| 21 | $zip->close(); |
||
| 22 | |||
| 23 | // Re-read it |
||
| 24 | $reader = new Xlsx(); |
||
| 25 | $spreadsheet = $reader->load($filename); |
||
| 26 | unlink($filename); |
||
| 27 | |||
| 28 | return $spreadsheet; |
||
| 29 | } |
||
| 31 |