php把資料輸出為word,並且資料中的img可顯示
阿新 • • 發佈:2019-01-09
$case_title1 =“abc”;
$content = "catwoe<span>implement<img src="http://www.baidu.com/04_20170109164233.jpg" alt="" /></span>"
$content = str_replace("src=\"/", "src=\"http://fangmingdesign.net/method/image/", $all_lists);//給是相對路徑的圖片加上域名變成絕對路徑,匯出來的word就會顯示圖片了
$filename = iconv('utf-8', 'gb2312', $case_title1);header('pragma:public');
header('Content-type:application/vnd.ms-word;charset=utf-8;name="'.$case_title1.'".doc');
header("Content-Disposition:attachment;filename=$filename.doc");//attachment新視窗列印inline本視窗列印
$html = '<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>';//這句不能少,否則不能識別圖片
echo $html.$content.'</html>';