php 批量生成 html轉word

function cword($data,$fileName=''){
        if(empty($data)) return '';
        $data='<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"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><xml><w:WordDocument><w:View>Print</w:View></xml></head>'.$data.'</html>';
        $dir   = "E:/project" .__ROOT__.'/ask/';
        if(!file_exists($dir))
            mkdir($dir,777,true);
        if(empty($fileName))
        {
            $fileName=$dir.date('His').'.doc';
        }
        else
        {
            $fileName =$dir.$fileName.'.doc';
        }
        $writefile=fopen($fileName,'wb') or die("創建文件失敗");//wb以二進制寫入
        fwrite($writefile,$data);
        fclose($writefile);
        return $fileName;
    }
 <xml><w:WordDocument><w:View>Print</w:View></xml>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章