예제 #1
0
 function exportToXls()
 {
     $database = JFactory::getDBO();
     $sqlQ = 'SELECT
             a.*, d.title AS catname, e.name as username,
             MAX(bbids.bid_price) as highest_bid
         FROM #__bid_auctions a
         LEFT JOIN #__bids as bbids ON bbids.auction_id=a.id
         LEFT JOIN #__categories d ON a.cat = d.id
         LEFT JOIN #__bid_users e ON a.userid = e.userid
         GROUP BY a.id';
     $database->setQuery($sqlQ);
     $result = $database->loadObjectList();
     $filename = 'Auction_Factory_Export_' . JHtml::date('now', 'd-M-Y_H-i-s') . '.xls';
     header("Content-type: application/vnd.ms-excel");
     header("Content-Disposition: attachment; filename=\"" . $filename . "\"");
     header("Expires: 0");
     header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
     header("Pragma: public");
     ob_clean();
     echo BidsHelperTools::createXLS($result);
     ob_end_flush();
     exit;
 }