copy row#4440
Conversation
|
You can probably clean up the phpcs and php-cs-fixer errors with: |
| @@ -1,5 +1,7 @@ | |||
| # PhpSpreadsheet | |||
|
|
|||
| BY JONATHAN | |||
There was a problem hiding this comment.
I don't know why these changes are here. Please delete them. There is space below in this file to describe the changes you are making.
| * @return void | ||
| */ | ||
| public function copyRow($from, $to) { | ||
| $this->getRowDimension($to)->setRowHeight($this->getRowDimension($from)->getRowHeight()); |
There was a problem hiding this comment.
Let's say you want to copy from row 1, which has cells A1/C1/E1, to row 2 which has cells A2/B2/F2. I think your code will replace A2/C2/E2 but leave B2/F2 unchanged, which is probably not what you want - you need to clear B2/F2.
| $toCellCoordinates = $fromCellIt->getColumn().$to; | ||
| // Cache data as trying to save the cells as variables doesn't work | ||
| $style = $this->getCell($fromCoordinates)->getStyle(); | ||
| $value = $this->getCell($fromCoordinates)->getValue(); |
There was a problem hiding this comment.
This might not be right for formulas. Let's say cell K3 has the value 10, and A1 has the value =1+K3. In Excel, if I now copy row 1 to row 2, cell A2 will have the value =1+K4. This is probably how your method should behave. It can get tricky. Rather than trying to re-invent the wheel, your loop should probably call copyCells for each cell that you want to copy. That will (I hope) update the formulas and take care of the styles.
|
In addition to other comments, you will need to add unit tests to demonstrate that your function works correctly. |
|
Hi!I dont know why i made a pull request. Im so sorry i made a mistake. I just wanted to make a fork to test some things. Enviado desde mi iPhoneEl 9 abr 2025, a las 17:40, oleibman ***@***.***> escribió:
In addition to other comments, you will need to add unit tests to demonstrate that your function works correctly.—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
oleibman left a comment (PHPOffice/PhpSpreadsheet#4440)
In addition to other comments, you will need to add unit tests to demonstrate that your function works correctly.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
|
|
According to author, it was unintentional to make this a pull request. Closing. |
This is:
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.