Conditions | 1 |
Paths | 1 |
Total Lines | 14 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
32 | private function readSpreadsheet(string $filename): Spreadsheet |
||
33 | { |
||
34 | // Assert that it is a valid ZIP file to prevent PhpSpreadsheet from hanging |
||
35 | $zip = new ZipArchive(); |
||
36 | $res = $zip->open($filename, ZipArchive::CHECKCONS); |
||
37 | self::assertTrue($res, 'exported Excel should be a valid ZIP file'); |
||
38 | $zip->close(); |
||
39 | |||
40 | // Re-read it |
||
41 | $reader = new Xlsx(); |
||
42 | $spreadsheet = $reader->load($filename); |
||
43 | unlink($filename); |
||
44 | |||
45 | return $spreadsheet; |
||
46 | } |
||
48 |