cell comment

Topics: Developer Forum, Project Management Forum, User Forum
Mar 1, 2012 at 5:48 PM

How to remove a comment for a cell?

Coordinator
Mar 1, 2012 at 6:22 PM

There's no specific method provided to remove a comment for a cell, but you can retrieve all the comments for a worksheet as an associative array, indexed by cell address... then just unset the entry for the cell you want to remove the comment from, and store that array back to the worksheet object.

$cellAddress = 'C3';
$allCellComments = $objPHPExcel->getActiveSheet()->getComments();
if (isset($allCellComments[$cellAddress]) {
    unset($allCellComments[$cellAddress]);
}
$objPHPExcel->getActiveSheet()->setComments($allCellComments);