2013-05-10 162 views
1
$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'); 

以上是我的代码,我运行它,并以Excel文件,如果环路的作品,因为我得到的输出,但它并没有在我的“untitled.xls”文件phpexcel不写数据使用setCellValueByColumnAndRow

做任何事

回答

1

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

那么你看到屏幕上的输出?

+0

感谢马克!有一堆phpexcel的问题,你总是与信息的人! – user1989379 2013-05-10 07:11:02