@@ -2581,22 +2581,31 @@ public function setComments(array $comments)
2581
2581
2582
2582
return $ this ;
2583
2583
}
2584
-
2585
2584
2586
2585
/**
2587
- * Remove comment.
2586
+ * Remove comment from cell .
2588
2587
*
2589
- * @param int $columnIndex Numeric column coordinate of the cell
2590
- * @param int $ row Numeric row coordinate of the cell
2588
+ * @param array< int>|CellAddress|string $cellCoordinate Coordinate of the cell as a string, eg: 'C5';
2589
+ * or as an array of [$columnIndex, $ row] (e.g. [3, 5]), or a CellAddress object.
2591
2590
*
2591
+ * @return Comment
2592
2592
*/
2593
- public function removeCommentByColumnAndRow ( $ columnIndex , $ row )
2593
+ public function removeComment ( $ cellCoordinate )
2594
2594
{
2595
- $ pCellCoordinate = strtoupper (Coordinate::stringFromColumnIndex ($ columnIndex ) . $ row );
2596
- if (isset ($ this ->comments [$ pCellCoordinate ])) {
2597
- unset($ this ->comments [$ pCellCoordinate ]);
2595
+ $ cellAddress = Functions::trimSheetFromCellReference (Validations::validateCellAddress ($ cellCoordinate ));
2596
+
2597
+ if (Coordinate::coordinateIsRange ($ cellAddress )) {
2598
+ throw new Exception ('Cell coordinate string can not be a range of cells. ' );
2599
+ } elseif (strpos ($ cellAddress , '$ ' ) !== false ) {
2600
+ throw new Exception ('Cell coordinate string must not be absolute. ' );
2601
+ } elseif ($ cellAddress == '' ) {
2602
+ throw new Exception ('Cell coordinate can not be zero-length string. ' );
2603
+ }
2604
+ // Check if we have a comment for this cell and delete it
2605
+ if (isset ($ this ->comments [$ cellAddress ])) {
2606
+ unset($ this ->comments [$ cellAddress ]);
2598
2607
}
2599
- }
2608
+ }
2600
2609
2601
2610
/**
2602
2611
* Get comment for cell.
0 commit comments