// 必要なクラスをインクルードする
set_include_path(get_include_path() . PATH_SEPARATOR . "./Classes/");
include "PHPExcel.php";
include "PHPExcel/IOFactory.php";
// PHPExcelオブジェクトを生成する
$book = new PHPExcel();
// シートの設定を行う
$book->setActiveSheetIndex(0);
$sheet = $book->getActiveSheet();
// セル「B2」に値をセットする
$sheet->setCellValueByColumnAndRow(1, 2, "ここにコメントあり!");
// セル「B2」にコメント作者をセットする
$sheet->getCommentByColumnAndRow(1, 2)->setAuthor("コメントした人");
// セル「B2」にコメントを書き込む
$sheet->getCommentByColumnAndRow(1, 2)->getText()->createTextRun("コメント:これはコメントです。");
// Excel2007形式で保存する
$writer = PHPExcel_IOFactory::createWriter($book, "Excel2007");
$writer->save("./output.xlsx");
[PHP - PHPExcel - セル操作]
セルに値をセットする 【setCellValueByColumnAndRow】
セルに式をセットする 【setCellValueByColumnAndRow】
セルの水平・垂直方向の文字位置を指定する 【PHPExcel_Style_Alignment】