1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xlsx; |
4
|
|
|
|
5
|
|
|
use PhpOffice\PhpSpreadsheet\IOFactory; |
6
|
|
|
use PhpOffice\PhpSpreadsheet\Style\Conditional; |
7
|
|
|
use PhpOffice\PhpSpreadsheetTests\Functional\AbstractFunctional; |
8
|
|
|
|
9
|
|
|
class ConditionalTest extends AbstractFunctional |
10
|
|
|
{ |
11
|
|
|
public function testLoadingConditionalDoesntLoseSelectedCell(): void |
12
|
|
|
{ |
13
|
|
|
$filename = 'tests/data/Reader/XLSX/ConditionalFormat_Ranges.xlsx'; |
14
|
|
|
$reader = IOFactory::createReader('Xlsx'); |
15
|
|
|
$spreadsheet = $reader->load($filename); |
16
|
|
|
$worksheet = $spreadsheet->getActiveSheet(); |
17
|
|
|
|
18
|
|
|
self::assertSame('A1', $worksheet->getActiveCell()); |
19
|
|
|
self::assertSame('A1', $worksheet->getSelectedCells()); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Test check if conditional style with type 'notContainsText' works on xlsx. |
24
|
|
|
*/ |
25
|
|
|
public function testConditionalNotContainsText(): void |
26
|
|
|
{ |
27
|
|
|
$filename = 'tests/data/Reader/XLSX/conditionalFormatting3Test.xlsx'; |
28
|
|
|
$reader = IOFactory::createReader('Xlsx'); |
29
|
|
|
$spreadsheet = $reader->load($filename); |
30
|
|
|
$worksheet = $spreadsheet->getActiveSheet(); |
31
|
|
|
$styles = $worksheet->getConditionalStyles('A1:A5'); |
32
|
|
|
|
33
|
|
|
self::assertCount(1, $styles); |
34
|
|
|
|
35
|
|
|
/** @var Conditional $notContainsTextStyle */ |
36
|
|
|
$notContainsTextStyle = $styles[0]; |
37
|
|
|
self::assertEquals('A', $notContainsTextStyle->getText()); |
38
|
|
|
self::assertEquals(Conditional::CONDITION_NOTCONTAINSTEXT, $notContainsTextStyle->getConditionType()); |
39
|
|
|
self::assertEquals(Conditional::OPERATOR_NOTCONTAINS, $notContainsTextStyle->getOperatorType()); |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
|