-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4247 from oleibman/issue4246
Swapped Row and Column Indexes in ReferenceHelper
- Loading branch information
Showing
3 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpOffice\PhpSpreadsheetTests; | ||
|
||
use PhpOffice\PhpSpreadsheet\Spreadsheet; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class ReferenceHelper5Test extends TestCase | ||
{ | ||
public function testIssue4246(): void | ||
{ | ||
// code below would have thrown exception because | ||
// row and column were swapped in code | ||
$spreadsheet = new Spreadsheet(); | ||
$sheet = $spreadsheet->getActiveSheet(); | ||
$row = 987654; | ||
$rowMinus1 = $row - 1; | ||
$rowPlus1 = $row + 1; | ||
$sheet->getCell("A$rowMinus1")->setValue(1); | ||
$sheet->getCell("B$rowMinus1")->setValue(2); | ||
$sheet->getCell("C$rowMinus1")->setValue(3); | ||
$sheet->getStyle("A$rowMinus1")->getFont()->setBold(true); | ||
$sheet->getCell("A$row")->setValue(1); | ||
$sheet->getCell("B$row")->setValue(2); | ||
$sheet->getCell("C$row")->setValue(3); | ||
$sheet->getStyle("B$row")->getFont()->setBold(true); | ||
|
||
$sheet->insertNewRowBefore($row); | ||
self::assertTrue( | ||
$sheet->getStyle("A$row")->getFont()->getBold() | ||
); | ||
self::assertFalse( | ||
$sheet->getStyle("B$row")->getFont()->getBold() | ||
); | ||
self::assertFalse( | ||
$sheet->getStyle("A$rowPlus1")->getFont()->getBold() | ||
); | ||
self::assertTrue( | ||
$sheet->getStyle("B$rowPlus1")->getFont()->getBold() | ||
); | ||
$spreadsheet->disconnectWorksheets(); | ||
} | ||
} |