Creating Comments

Topics: Developer Forum
Nov 19, 2008 at 2:37 PM
Edited Nov 19, 2008 at 2:40 PM
I was trying to add a comment to a cell.  I used the exact code from the documentation, but the comment did not appear.  What did I do wrong?


 

 

$objReader = PHPExcel_IOFactory::createReader('Excel5');

$objPHPExcel = $objReader->load('Q:\stw\stw_php\stwconv\Account_Conversions\Spreadsheets\account_changes-v2.xls');

$objPHPExcel->setActiveSheetIndex(0);

$input_sheet = $objPHPExcel->getActiveSheet();


// ---- Create an Excel Comment 

$objPHPExcel->getActiveSheet()->getComment('E11')->setAuthor('PHPExcel');

$objCommentRichText = $objPHPExcel->getActiveSheet()->getComment('E11')->getText()->createTextRun('PHPExcel:');

$objCommentRichText->getFont()->setBold(true);

$objPHPExcel->getActiveSheet()->getComment('E11')->getText()->createTextRun("\r\n");

$objPHPExcel->getActiveSheet()->getComment('E11')->getText()->createTextRun('Total amount on the current invoice, excluding VAT.');

 

 

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');

$objWriter->save("test-account_changes.xls");

 

 

 

 

 

Developer
Nov 19, 2008 at 2:48 PM
I'm afraid that comments are not supported in Excel5 reader/writer. You may have to resort to Excel2007 reader/writer. There is rather poor documentation on how comments are stored in BIFF8 (Excel 97-2003) files. BIFF5 (Excel 5.0-95) was much simpler. Yet, it is probably possible to add support in Excel5 reader/writer if one studies hard enough. Until then, sorry...