PhpSpreadsheet/tests/PhpSpreadsheetTests/Reader/XlsxTest.php

48 lines
1.5 KiB
PHP
Raw Normal View History

<?php
namespace PhpOffice\PhpSpreadsheetTests\Reader;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx as ReaderXlsx;
use PhpOffice\PhpSpreadsheet\Shared\File;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx as WriterXlsx;
use PHPUnit\Framework\TestCase;
class XlsxTest extends TestCase
{
/**
* Test load Xlsx file without cell reference.
*/
public function testLoadXlsxWithoutCellReference()
{
$filename = './data/Reader/XLSX/without_cell_reference.xlsx';
$reader = new ReaderXlsx();
$reader->load($filename);
}
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');
}
}