Reputation: 822
I am using PHPExcel to put some comments to cells. But if I put range, than I see error:
Cell coordinate string can not be a range of cells.
I need a function that can convert my range to array of cells for loop.
For example, if I have (A6:A11) => array(A6, A7, A8, A9, A10, A11).
How to do it?
Upvotes: 1
Views: 563
Reputation: 212412
You can't specify a range of cells when using the need to set each comment individually
But there is a helper function that will allow you to split a range string to an array of individual cell addresses that you can then loop over:
foreach(PHPExcel_Cell::extractAllCellReferencesInRange('A6:A11') as $cellAddress) {
$objCommentRichText = $objPHPExcel->getActiveSheet()
->getComment($cellAddress)
->getText()
->createTextRun('My comment for all cells in the range A6 to A11');
}
Upvotes: 1