Ods reader: fix sheet count and added a test for sheet names
This commit is contained in:
parent
b50ca6e27c
commit
c954eddf57
|
@ -435,7 +435,9 @@ class Ods extends BaseReader implements IReader
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create sheet
|
// Create sheet
|
||||||
$spreadsheet->createSheet();
|
if($worksheetID > 0){
|
||||||
|
$spreadsheet->createSheet(); // First sheet is added by default
|
||||||
|
}
|
||||||
$spreadsheet->setActiveSheetIndex($worksheetID);
|
$spreadsheet->setActiveSheetIndex($worksheetID);
|
||||||
|
|
||||||
if ($worksheetName) {
|
if ($worksheetName) {
|
||||||
|
|
|
@ -13,9 +13,7 @@ use PhpOffice\PhpSpreadsheet\Reader\Ods;
|
||||||
use PhpOffice\PhpSpreadsheet\Style\Font;
|
use PhpOffice\PhpSpreadsheet\Style\Font;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @todo Fix sheet name (is not imported correctly)
|
* @todo The class doesn't read the bold/italic/underline properties (rich text)
|
||||||
* @todo Sheets count is incorrect
|
|
||||||
* @todo The class doesn't read the bold/italic/underline properties
|
|
||||||
*/
|
*/
|
||||||
class OdsTest extends \PHPUnit_Framework_TestCase
|
class OdsTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
@ -61,13 +59,28 @@ class OdsTest extends \PHPUnit_Framework_TestCase
|
||||||
return $this->spreadsheetData;
|
return $this->spreadsheetData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testReadFileProperties()
|
||||||
|
{
|
||||||
|
$filename = __DIR__ . '/../../data/Reader/Ods/data.ods';
|
||||||
|
|
||||||
|
// Load into this instance
|
||||||
|
$reader = new Ods();
|
||||||
|
|
||||||
|
// Test "listWorksheetNames" method
|
||||||
|
|
||||||
|
$this->assertEquals([
|
||||||
|
"Sheet1",
|
||||||
|
"Second Sheet",
|
||||||
|
], $reader->listWorksheetNames($filename));
|
||||||
|
}
|
||||||
|
|
||||||
public function testLoadWorksheets()
|
public function testLoadWorksheets()
|
||||||
{
|
{
|
||||||
$spreadsheet = $this->loadDataFile();
|
$spreadsheet = $this->loadDataFile();
|
||||||
|
|
||||||
$this->assertInstanceOf('PhpOffice\PhpSpreadsheet\Spreadsheet', $spreadsheet);
|
$this->assertInstanceOf('PhpOffice\PhpSpreadsheet\Spreadsheet', $spreadsheet);
|
||||||
|
|
||||||
// $this->assertCount(1, $spreadsheet->getAllSheets());
|
$this->assertEquals(2, $spreadsheet->getSheetCount());
|
||||||
|
|
||||||
$firstSheet = $spreadsheet->getSheet(0);
|
$firstSheet = $spreadsheet->getSheet(0);
|
||||||
$this->assertInstanceOf('PhpOffice\PhpSpreadsheet\Worksheet', $firstSheet);
|
$this->assertInstanceOf('PhpOffice\PhpSpreadsheet\Worksheet', $firstSheet);
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue