mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-28 11:07:52 +00:00
a2edbf8776
* Unzipped Gnumeric File A Gnumeric file is normally a gzipped Xml file. However, the Gnumeric application will also read an unzipped Xml file. Allow PhpSpreadsheet to do the same. * Scrutinizer (legitimate) Fix minor problem.
63 lines
1.9 KiB
PHP
63 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Reader\Gnumeric;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Reader\Exception as ReaderException;
|
|
use PhpOffice\PhpSpreadsheet\Reader\Gnumeric;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class GnumericInfoTest extends TestCase
|
|
{
|
|
public function testListNames(): void
|
|
{
|
|
$filename = 'samples/templates/GnumericTest.gnumeric';
|
|
$reader = new Gnumeric();
|
|
$names = $reader->listWorksheetNames($filename);
|
|
self::assertCount(2, $names);
|
|
self::assertEquals('Sample Data', $names[0]);
|
|
self::assertEquals('Report Data', $names[1]);
|
|
}
|
|
|
|
public function testListInfo(): void
|
|
{
|
|
$filename = 'samples/templates/GnumericTest.gnumeric';
|
|
$reader = new Gnumeric();
|
|
$info = $reader->listWorksheetInfo($filename);
|
|
$expected = [
|
|
[
|
|
'worksheetName' => 'Sample Data',
|
|
'lastColumnLetter' => 'N',
|
|
'lastColumnIndex' => 13,
|
|
'totalRows' => 31,
|
|
'totalColumns' => 14,
|
|
],
|
|
[
|
|
'worksheetName' => 'Report Data',
|
|
'lastColumnLetter' => 'K',
|
|
'lastColumnIndex' => 10,
|
|
'totalRows' => 65535,
|
|
'totalColumns' => 11,
|
|
],
|
|
];
|
|
self::assertEquals($expected, $info);
|
|
}
|
|
|
|
public function testListNamesNotGumeric(): void
|
|
{
|
|
$this->expectException(ReaderException::class);
|
|
$this->expectExceptionMessage('invalid Gnumeric file');
|
|
$filename = 'samples/templates/excel2003.xml';
|
|
$reader = new Gnumeric();
|
|
$reader->listWorksheetNames($filename);
|
|
}
|
|
|
|
public function testListInfoNotXml(): void
|
|
{
|
|
$this->expectException(ReaderException::class);
|
|
$this->expectExceptionMessage('invalid Gnumeric file');
|
|
$filename = __FILE__;
|
|
$reader = new Gnumeric();
|
|
$reader->listWorksheetInfo($filename);
|
|
}
|
|
}
|