2013-05-10 58 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