Answer the question
In order to leave comments, you need to log in
How to remove/overwrite a comment in a PHPExcel cell?
Good afternoon!
I use PHPExcel to work with Excel.
It is necessary to overwrite the comment in the cell, but it turns out only to append to the end with this code:
$objPHPExcel = PHPExcel_IOFactory::load('./test.xlsx');
$objPHPExcel->getActiveSheet()->getComment('E11')->getText()->createTextRun("testtesttest");
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, "Excel2007");
$objWriter->save('./test.xlsx');
Answer the question
In order to leave comments, you need to log in
You need to use the setText() method :
$objPHPExcel = PHPExcel_IOFactory::load('./test.xlsx');
$comment = $objPHPExcel->getActiveSheet()->getComment('E11');
$commentText = new PHPExcel_RichText;
$commentText->createText("testtesttest");
$comment->setText($commentText);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, "Excel2007");
$objWriter->save('./test.xlsx');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question