Skip to content

Commit

Permalink
Add test for table read when IReader:::READ_DATA_ONLY is used
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Verschaeve committed Sep 13, 2023
1 parent f1025b6 commit 15e12ca
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/PhpSpreadsheetTests/Reader/Xlsx/XlsxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Reader\IReader;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use PhpOffice\PhpSpreadsheet\Shared\File;
use PhpOffice\PhpSpreadsheet\Style\Conditional;
Expand Down Expand Up @@ -245,4 +246,22 @@ public static function providerStripsWhiteSpaceFromStyleString(): array
height:13.5pt;z-index:5;mso-wrap-style:tight'],
];
}

public function testLoadDataOnlyLoadsAlsoTables(): void
{
$filename = 'tests/data/Reader/XLSX/data_with_tables.xlsx';
$reader = new Xlsx();
$excel = $reader->load($filename, IReader::READ_DATA_ONLY);

self::assertEquals(['First', 'Second'], $excel->getSheetNames());
self::assertEquals('A1:B5', $excel->getTableByName('Tableau1')->getRange());
self::assertEquals([['1', '2', '3']], $excel->getSheetByName('First')->toArray());
self::assertEquals([
['Colonne1', 'Colonne2'],
['a', 'b',],
['c', 'd'],
['e', 'f'],
['g', 'h'],
], $excel->getSheetByName('Second')->toArray());
}
}
Binary file added tests/data/Reader/XLSX/data_with_tables.xlsx
Binary file not shown.

0 comments on commit 15e12ca

Please sign in to comment.