|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace PhpOffice\PhpSpreadsheetTests\Reader\Xls; |
| 4 | + |
| 5 | +use PhpOffice\PhpSpreadsheet\Reader\Xls; |
| 6 | +use PHPUnit\Framework\TestCase; |
| 7 | + |
| 8 | +class InfoNamesTest extends TestCase |
| 9 | +{ |
| 10 | + public function testWorksheetNamesBiff5(): void |
| 11 | + { |
| 12 | + $filename = 'samples/templates/30templatebiff5.xls'; |
| 13 | + $reader = new Xls(); |
| 14 | + $names = $reader->listWorksheetNames($filename); |
| 15 | + $expected = ['Invoice', 'Terms and conditions']; |
| 16 | + self::assertSame($expected, $names); |
| 17 | + } |
| 18 | + |
| 19 | + public function testWorksheetInfoBiff5(): void |
| 20 | + { |
| 21 | + $filename = 'samples/templates/30templatebiff5.xls'; |
| 22 | + $reader = new Xls(); |
| 23 | + $info = $reader->listWorksheetInfo($filename); |
| 24 | + $expected = [ |
| 25 | + [ |
| 26 | + 'worksheetName' => 'Invoice', |
| 27 | + 'lastColumnLetter' => 'E', |
| 28 | + 'lastColumnIndex' => 4, |
| 29 | + 'totalRows' => 19, |
| 30 | + 'totalColumns' => 5, |
| 31 | + ], |
| 32 | + [ |
| 33 | + 'worksheetName' => 'Terms and conditions', |
| 34 | + 'lastColumnLetter' => 'B', |
| 35 | + 'lastColumnIndex' => 1, |
| 36 | + 'totalRows' => 3, |
| 37 | + 'totalColumns' => 2, |
| 38 | + ], |
| 39 | + ]; |
| 40 | + self::assertSame($expected, $info); |
| 41 | + } |
| 42 | + |
| 43 | + public function testWorksheetNamesBiff8(): void |
| 44 | + { |
| 45 | + $filename = 'samples/templates/31docproperties.xls'; |
| 46 | + $reader = new Xls(); |
| 47 | + $names = $reader->listWorksheetNames($filename); |
| 48 | + $expected = ['Worksheet']; |
| 49 | + self::assertSame($expected, $names); |
| 50 | + } |
| 51 | + |
| 52 | + public function testWorksheetInfoBiff8(): void |
| 53 | + { |
| 54 | + $filename = 'samples/templates/31docproperties.xls'; |
| 55 | + $reader = new Xls(); |
| 56 | + $info = $reader->listWorksheetInfo($filename); |
| 57 | + $expected = [ |
| 58 | + [ |
| 59 | + 'worksheetName' => 'Worksheet', |
| 60 | + 'lastColumnLetter' => 'B', |
| 61 | + 'lastColumnIndex' => 1, |
| 62 | + 'totalRows' => 1, |
| 63 | + 'totalColumns' => 2, |
| 64 | + ], |
| 65 | + ]; |
| 66 | + self::assertSame($expected, $info); |
| 67 | + } |
| 68 | + |
| 69 | + public function testWorksheetNamesBiff8Mac(): void |
| 70 | + { |
| 71 | + // Non-standard codepage |
| 72 | + $filename = 'tests/data/Reader/XLS/maccentraleurope.xls'; |
| 73 | + $reader = new Xls(); |
| 74 | + $names = $reader->listWorksheetNames($filename); |
| 75 | + $expected = ['Arkusz1']; |
| 76 | + self::assertSame($expected, $names); |
| 77 | + } |
| 78 | + |
| 79 | + public function testWorksheetInfoBiff8Mac(): void |
| 80 | + { |
| 81 | + $filename = 'tests/data/Reader/XLS/maccentraleurope.xls'; |
| 82 | + $reader = new Xls(); |
| 83 | + $info = $reader->listWorksheetInfo($filename); |
| 84 | + $expected = [ |
| 85 | + [ |
| 86 | + 'worksheetName' => 'Arkusz1', |
| 87 | + 'lastColumnLetter' => 'P', |
| 88 | + 'lastColumnIndex' => 15, |
| 89 | + 'totalRows' => 3, |
| 90 | + 'totalColumns' => 16, |
| 91 | + ], |
| 92 | + ]; |
| 93 | + self::assertSame($expected, $info); |
| 94 | + } |
| 95 | +} |
0 commit comments