1. 程式人生 > >php中table匯出為Excel

php中table匯出為Excel

public function save_as_excel($f3){
		$filename = 'report';
		header("Content-type: application/vnd.ms-excel");
		header("Content-Disposition: attachment;Filename=".$filename.".xls");
		echo "<html>";
		echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">";
		echo "<body>";
		echo stripslashes($_POST['data']);
		echo "</body>";
		echo "</html>";

	}

以上程式碼摘自opencar的一個外掛,很有參考性,我認為可以擴充套件為直接匯出資料庫內容作為報表而不用第三方報表控制元件。