phpexcel不写数据到excel文件使用setCellValueByColumnAndRow


phpexcel not writing data to excel file using setCellValueByColumnAndRow

$objPHPExcel = PHPExcel_IOFactory::load("untitled.xls");
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) //loop through the 3 worksheets of KindleEditionEISBN
{
$sheet_name = $worksheet->getTitle();  
if ($worksheet->getTitle = 'Records')
{
$highestColumm = $objPHPExcel->setActiveSheetIndex(0)->getHighestColumn();
$highestRow = $objPHPExcel->setActiveSheetIndex(0)->getHighestRow();
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($highestColumm, $highestRow, $node_10); 
$objWriter2007 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter2007->save('php://output');

以上是我的代码,我运行它,if循环工作,因为我得到了输出,但它没有在我的"untitled.xls"文件

做任何事情

这段代码不会写任何东西到untitled.xls,因为你保存到php://output(屏幕),所以文件的内容应该显示在屏幕上,除非你也发送头告诉浏览器将输出作为Excel文件;并且您使用Excel2007 Writer将输出生成为OfficeOpenXML格式的xlsx文件,而不是作为BIFF格式的xls文件。

那么你在屏幕上看到输出了吗?