2017-09-22 05:49:38 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Reader;
|
|
|
|
|
2017-12-16 16:20:50 +00:00
|
|
|
use PhpOffice\PhpSpreadsheet\Reader\Xlsx as ReaderXlsx;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Shared\File;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Writer\Xlsx as WriterXlsx;
|
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-16 16:20:50 +00:00
|
|
|
$reader = new ReaderXlsx();
|
2017-09-22 05:49:38 +00:00
|
|
|
$reader->load($filename);
|
|
|
|
}
|
2017-12-16 16:20:50 +00:00
|
|
|
|
|
|
|
public function testFreezePane()
|
|
|
|
{
|
|
|
|
$filename = tempnam(File::sysGetTempDir(), 'phpspreadsheet');
|
|
|
|
|
|
|
|
$cellSplit = 'B2';
|
|
|
|
$topLeftCell = 'E5';
|
|
|
|
|
|
|
|
$spreadsheet = new Spreadsheet();
|
|
|
|
$active = $spreadsheet->getActiveSheet();
|
|
|
|
$active->freezePane($cellSplit, $topLeftCell);
|
|
|
|
|
|
|
|
$writer = new WriterXlsx($spreadsheet);
|
|
|
|
$writer->save($filename);
|
|
|
|
|
|
|
|
// Read written file
|
|
|
|
$reader = new ReaderXlsx();
|
|
|
|
$reloadedSpreadsheet = $reader->load($filename);
|
|
|
|
$reloadedActive = $reloadedSpreadsheet->getActiveSheet();
|
|
|
|
$actualCellSplit = $reloadedActive->getFreezePane();
|
|
|
|
$actualTopLeftCell = $reloadedActive->getTopLeftCell();
|
|
|
|
|
|
|
|
self::assertSame($cellSplit, $actualCellSplit, 'should be able to set freeze pane');
|
|
|
|
self::assertSame($topLeftCell, $actualTopLeftCell, 'should be able to set the top left cell');
|
|
|
|
}
|
2017-09-22 05:49:38 +00:00
|
|
|
}
|