Skip to content

Commit

Permalink
cs fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
sibalonat committed Feb 6, 2024
1 parent 1a827fe commit c612436
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 26 deletions.
42 changes: 22 additions & 20 deletions src/PhpSpreadsheet/Worksheet/Worksheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@
namespace PhpOffice\PhpSpreadsheet\Worksheet;

use ArrayObject;
use PhpOffice\PhpSpreadsheet\Shared;
use PhpOffice\PhpSpreadsheet\Comment;
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Cell\AddressRange;
use PhpOffice\PhpSpreadsheet\Cell\Cell;
use PhpOffice\PhpSpreadsheet\Exception;
use PhpOffice\PhpSpreadsheet\Cell\CellAddress;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Cell\DataType;
use PhpOffice\PhpSpreadsheet\Cell\DataValidation;
use PhpOffice\PhpSpreadsheet\Cell\Hyperlink;
use PhpOffice\PhpSpreadsheet\Cell\IValueBinder;
use PhpOffice\PhpSpreadsheet\Chart\Chart;
use PhpOffice\PhpSpreadsheet\Collection\Cells;
use PhpOffice\PhpSpreadsheet\Collection\CellsFactory;
use PhpOffice\PhpSpreadsheet\Comment;
use PhpOffice\PhpSpreadsheet\DefinedName;
use PhpOffice\PhpSpreadsheet\Exception;
use PhpOffice\PhpSpreadsheet\IComparable;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Style\Color;
use PhpOffice\PhpSpreadsheet\Style\Style;
use PhpOffice\PhpSpreadsheet\Cell\DataType;
use PhpOffice\PhpSpreadsheet\Cell\Hyperlink;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\ReferenceHelper;
use PhpOffice\PhpSpreadsheet\Style\Alignment;
use PhpOffice\PhpSpreadsheet\Cell\CellAddress;
use PhpOffice\PhpSpreadsheet\Collection\Cells;
use PhpOffice\PhpSpreadsheet\Cell\AddressRange;
use PhpOffice\PhpSpreadsheet\Cell\IValueBinder;
use PhpOffice\PhpSpreadsheet\RichText\RichText;
use PhpOffice\PhpSpreadsheet\Shared;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Style\Alignment;
use PhpOffice\PhpSpreadsheet\Style\Color;
use PhpOffice\PhpSpreadsheet\Style\Conditional;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
use PhpOffice\PhpSpreadsheet\Cell\DataValidation;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
use PhpOffice\PhpSpreadsheet\Collection\CellsFactory;
use PhpOffice\PhpSpreadsheet\Style\Protection as StyleProtection;
use PhpOffice\PhpSpreadsheet\Style\Style;

class Worksheet implements IComparable
{
Expand Down Expand Up @@ -3641,7 +3641,8 @@ public function repeatSourceRange(string $sourceRange, int $repetitions = 2, int
// Copy the cells and merge them in the new locations
$groupCount = 0;
$rowOffset = 0;
for ($i = 1; $i <= $repetitions + 1; $i++) {

for ($i = 1; $i <= $repetitions + 1; ++$i) {
if ($i % $groupSize != 1 && $i > $groupSize) {
$offset = ($i - 1) % $groupSize * ($sourceEndColumnIndex - $sourceStartColumnIndex + 1);
} else {
Expand Down Expand Up @@ -3682,7 +3683,8 @@ public function repeatSourceRange(string $sourceRange, int $repetitions = 2, int
// Increase group count and row offset after every groupSize repetitions
if ($i % $groupSize == 0) {
$rowOffset += $sourceEnd[1] - $sourceStart[1] + 2; // 2 is the number of rows to skip
$groupCount++;

++$groupCount;
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions tests/PhpSpreadsheetTests/Worksheet/WorksheetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -651,13 +651,13 @@ public function testRepeatSourceRangeBasic(): void
$worksheet->repeatSourceRange($sourceRange, $repetitions, $groupSize);

// Assert that cells are copied correctly
$this->assertEquals('Test1', $worksheet->getCell('A1')->getValue());
$this->assertEquals('Test3', $worksheet->getCell('A2')->getValue());
$this->assertEquals('Test5', $worksheet->getCell('A3')->getValue());
self::assertEquals('Test1', $worksheet->getCell('A1')->getValue());
self::assertEquals('Test3', $worksheet->getCell('A2')->getValue());
self::assertEquals('Test5', $worksheet->getCell('A3')->getValue());

// Assert that merged cells are copied correctly
$this->assertContains('A1:B1', $worksheet->getMergeCells());
$this->assertContains('A2:B2', $worksheet->getMergeCells());
$this->assertContains('A3:B3', $worksheet->getMergeCells());
self::assertContains('A1:B1', $worksheet->getMergeCells());
self::assertContains('A2:B2', $worksheet->getMergeCells());
self::assertContains('A3:B3', $worksheet->getMergeCells());
}
}

0 comments on commit c612436

Please sign in to comment.