@@ -703,6 +703,7 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet
703
703
// Parse the individual sheets
704
704
$ this ->activeSheetSet = false ;
705
705
foreach ($ this ->sheets as $ sheet ) {
706
+ $ selectedCells = '' ;
706
707
if ($ sheet ['sheetType ' ] != 0x00 ) {
707
708
// 0x00: Worksheet, 0x02: Chart, 0x06: Visual Basic module
708
709
continue ;
@@ -910,7 +911,7 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet
910
911
911
912
break ;
912
913
case self ::XLS_TYPE_SELECTION :
913
- $ this ->readSelection ();
914
+ $ selectedCells = $ this ->readSelection ();
914
915
915
916
break ;
916
917
case self ::XLS_TYPE_MERGEDCELLS :
@@ -1112,6 +1113,9 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet
1112
1113
$ this ->phpSheet ->getComment ($ cellAddress )->setAuthor ($ noteDetails ['author ' ])->setText ($ this ->parseRichText ($ noteDetails ['objTextData ' ]['text ' ]));
1113
1114
}
1114
1115
}
1116
+ if ($ selectedCells !== '' ) {
1117
+ $ this ->phpSheet ->setSelectedCells ($ selectedCells );
1118
+ }
1115
1119
}
1116
1120
if ($ this ->activeSheetSet === false ) {
1117
1121
$ this ->spreadsheet ->setActiveSheetIndex (0 );
@@ -4376,10 +4380,11 @@ private function readPane(): void
4376
4380
/**
4377
4381
* Read SELECTION record. There is one such record for each pane in the sheet.
4378
4382
*/
4379
- private function readSelection (): void
4383
+ private function readSelection (): string
4380
4384
{
4381
4385
$ length = self ::getUInt2d ($ this ->data , $ this ->pos + 2 );
4382
4386
$ recordData = $ this ->readRecordData ($ this ->data , $ this ->pos + 4 , $ length );
4387
+ $ selectedCells = '' ;
4383
4388
4384
4389
// move stream pointer to next record
4385
4390
$ this ->pos += 4 + $ length ;
@@ -4421,6 +4426,8 @@ private function readSelection(): void
4421
4426
4422
4427
$ this ->phpSheet ->setSelectedCells ($ selectedCells );
4423
4428
}
4429
+
4430
+ return $ selectedCells ;
4424
4431
}
4425
4432
4426
4433
private function includeCellRangeFiltered (string $ cellRangeAddress ): bool
@@ -7410,6 +7417,7 @@ private function readCFRule(array $cellRangeAddresses): void
7410
7417
$ options = self ::getInt4d ($ recordData , 6 );
7411
7418
7412
7419
$ style = new Style (false , true ); // non-supervisor, conditional
7420
+ $ noFormatSet = true ;
7413
7421
//$this->getCFStyleOptions($options, $style);
7414
7422
7415
7423
$ hasFontRecord = (bool ) ((0x04000000 & $ options ) >> 26 );
@@ -7429,6 +7437,7 @@ private function readCFRule(array $cellRangeAddresses): void
7429
7437
$ fontStyle = substr ($ recordData , $ offset , 118 );
7430
7438
$ this ->getCFFontStyle ($ fontStyle , $ style );
7431
7439
$ offset += 118 ;
7440
+ $ noFormatSet = false ;
7432
7441
}
7433
7442
7434
7443
if ($ hasAlignmentRecord === true ) {
@@ -7441,12 +7450,14 @@ private function readCFRule(array $cellRangeAddresses): void
7441
7450
$ borderStyle = substr ($ recordData , $ offset , 8 );
7442
7451
$ this ->getCFBorderStyle ($ borderStyle , $ style , $ hasBorderLeft , $ hasBorderRight , $ hasBorderTop , $ hasBorderBottom );
7443
7452
$ offset += 8 ;
7453
+ $ noFormatSet = false ;
7444
7454
}
7445
7455
7446
7456
if ($ hasFillRecord === true ) {
7447
7457
$ fillStyle = substr ($ recordData , $ offset , 4 );
7448
7458
$ this ->getCFFillStyle ($ fillStyle , $ style );
7449
7459
$ offset += 4 ;
7460
+ $ noFormatSet = false ;
7450
7461
}
7451
7462
7452
7463
if ($ hasProtectionRecord === true ) {
@@ -7474,7 +7485,7 @@ private function readCFRule(array $cellRangeAddresses): void
7474
7485
$ offset += $ size2 ;
7475
7486
}
7476
7487
7477
- $ this ->setCFRules ($ cellRangeAddresses , $ type , $ operator , $ formula1 , $ formula2 , $ style );
7488
+ $ this ->setCFRules ($ cellRangeAddresses , $ type , $ operator , $ formula1 , $ formula2 , $ style, $ noFormatSet );
7478
7489
}
7479
7490
7480
7491
/*private function getCFStyleOptions(int $options, Style $style): void
@@ -7604,12 +7615,14 @@ private function readCFFormula(string $recordData, int $offset, int $size): floa
7604
7615
}
7605
7616
}
7606
7617
7607
- private function setCFRules (array $ cellRanges , string $ type , string $ operator , null |float |int |string $ formula1 , null |float |int |string $ formula2 , Style $ style ): void
7618
+ private function setCFRules (array $ cellRanges , string $ type , string $ operator , null |float |int |string $ formula1 , null |float |int |string $ formula2 , Style $ style, bool $ noFormatSet ): void
7608
7619
{
7609
7620
foreach ($ cellRanges as $ cellRange ) {
7610
7621
$ conditional = new Conditional ();
7622
+ $ conditional ->setNoFormatSet ($ noFormatSet );
7611
7623
$ conditional ->setConditionType ($ type );
7612
7624
$ conditional ->setOperatorType ($ operator );
7625
+ $ conditional ->setStopIfTrue (true );
7613
7626
if ($ formula1 !== null ) {
7614
7627
$ conditional ->addCondition ($ formula1 );
7615
7628
}
0 commit comments