Issue2488Test.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheetTests\Reader\Xlsx;
  3. use PhpOffice\PhpSpreadsheet\IOFactory;
  4. use PHPUnit\Framework\TestCase;
  5. class Issue2488Test extends TestCase
  6. {
  7. /**
  8. * @var string
  9. */
  10. private static $testbook = 'tests/data/Reader/XLSX/issue.2488.xlsx';
  11. public function testPreliminaries(): void
  12. {
  13. $file = 'zip://';
  14. $file .= self::$testbook;
  15. $file .= '#xl/worksheets/sheet1.xml';
  16. $data = file_get_contents($file);
  17. // confirm that file contains expected namespaced xml tag
  18. if ($data === false) {
  19. self::fail('Unable to read file');
  20. } else {
  21. self::assertStringContainsString('<c r="E1" t="n" />', $data);
  22. self::assertStringContainsString('<c r="E2" t="s" />', $data);
  23. self::assertStringContainsString('<c r="D3" t="b" />', $data);
  24. }
  25. }
  26. public function testIssue2450(): void
  27. {
  28. // Cell explicitly typed as numeric but without value.
  29. $filename = self::$testbook;
  30. $reader = IOFactory::createReader('Xlsx');
  31. $spreadsheet = $reader->load($filename);
  32. $sheet = $spreadsheet->getActiveSheet();
  33. // E1 and D3 are numeric/boolean without value.
  34. // So is E2, but I don't see a practical difference
  35. // between null string and null in that case.
  36. $expected = [
  37. [1, 2, 3, 0, null, -1, -2, -3],
  38. ['a', 'b', 'c', 'xxx', '', 'd', 'e', 'f'],
  39. [false, false, false, null, true, true, true, true],
  40. ];
  41. self::assertSame($expected, $sheet->toArray());
  42. $spreadsheet->disconnectWorksheets();
  43. }
  44. }