2017-09-22 05:49:38 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Reader;
|
|
|
|
|
2017-12-17 07:34:40 +00:00
|
|
|
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
|
2017-11-08 15:48:01 +00:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2017-09-22 05:49:38 +00:00
|
|
|
|
2017-11-08 15:48:01 +00:00
|
|
|
class XlsxTest extends TestCase
|
2017-09-22 05:49:38 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Test load Xlsx file without cell reference.
|
|
|
|
*/
|
|
|
|
public function testLoadXlsxWithoutCellReference()
|
|
|
|
{
|
|
|
|
$filename = './data/Reader/XLSX/without_cell_reference.xlsx';
|
2017-12-17 07:34:40 +00:00
|
|
|
$reader = new Xlsx();
|
2017-09-22 05:49:38 +00:00
|
|
|
$reader->load($filename);
|
|
|
|
}
|
2018-11-19 13:48:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test load Xlsx file and use a read filter.
|
|
|
|
*/
|
|
|
|
public function testLoadWithReadFilter()
|
|
|
|
{
|
|
|
|
$filename = './data/Reader/XLSX/without_cell_reference.xlsx';
|
|
|
|
$reader = new Xlsx();
|
|
|
|
$reader->setReadFilter(new OddColumnReadFilter());
|
|
|
|
$data = $reader->load($filename)->getActiveSheet()->toArray();
|
|
|
|
$ref = [1.0, null, 3.0, null, 5.0, null, 7.0, null, 9.0, null];
|
|
|
|
|
|
|
|
for ($i = 0; $i < 10; ++$i) {
|
|
|
|
$this->assertEquals($ref, \array_slice($data[$i], 0, 10, true));
|
|
|
|
}
|
|
|
|
}
|
2017-09-22 05:49:38 +00:00
|
|
|
}
|