Feature Request - repeatSourceRange Functionality in Worksheet #3895
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is:
Related to issue: #3894
Checklist:
Why this change is needed?
Provide an explanation of why this change is needed, with links to any Issues (if appropriate).
If this is a bugfix or a new feature, and there are no existing Issues, then please also create an issue that will make it easier to track progress with this PR.
Description:
This pull request introduces a new feature in the Worksheet class, the repeatSourceRange function. This function allows users to repeat a specified source range of cells multiple times in the worksheet. This is particularly useful when there is a need to duplicate a certain pattern or format of cells in a worksheet.
The repeatSourceRange function takes three parameters:
$worksheet: The worksheet where the source range is located and where the repetitions will be placed.
$sourceRange: The range of cells to be copied.
$repetitions: The number of times the source range should be repeated.
$groupSize: The number of rows in each group of repetitions.
Benefits:
Efficiency: This feature saves users from the tedious task of manually copying and pasting a range of cells multiple times. It automates the process, making it more efficient and less error-prone.
Consistency: By using this function, users can ensure that the repeated cells are identical, maintaining consistency in the worksheet.
Flexibility: This function is flexible and can be used in a variety of scenarios, such as creating multiple instances of a template within a worksheet, duplicating patterns, and more.
Ease of Use: This function is easy to use and integrates seamlessly with the existing PhpSpreadsheet library. Users can easily incorporate it into their projects without any major changes to their existing code.
Changes:
The main change is the addition of the repeatSourceRange function in the Worksheet class. Unit tests have also been added to ensure the correct functionality of this feature.
Testing:
Unit tests have been added to test the repeatSourceRange function. The tests cover basic functionality, such as copying cells and merged cells, and ensure that the cells are copied to the correct locations.
Please review and let me know if there are any changes or improvements needed