// Export results
require_once('PHPExcel.php');
$query = "SELECT DISTINCT TITLE, PID, TYPE, SUM(DAYCOUNT) AS tot, ROUND(SUM(DAYCOUNT)/( SELECT SUM(DAYCOUNT) FROM REPORT_LIST_VIEW), 4) AS per FROM REPORT_LIST_VIEW WHERE DAYCOUNT > '0' GROUP BY TITLE, PID, TYPE ORDER BY tot DESC";
if ($result = db_query($query)) {
// Create a new PHPExcel object
$objPHPExcel = new PHPExcel();
$objPHPExcel->getActiveSheet()->setTitle('List of Cities');
// Loop through the result set
$rowNumber = 1;
while ($row = $result->fetchAssoc()) {
$objPHPExcel->getActiveSheet()->fromArray($row,NULL,'A'.$rowNumber++);
}
// Save as an Excel BIFF (xls) file
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('CityList.xls');
}
我在PHP页面中尝试使用此代码将Oracle的查询结果作为Excel文件下载,但是当我浏览到该页面时,它都是空白的,就像挂起一样。
任何线索?