html生成word文档并下载

/**
 * @desc生成word文档并下载
 * @param $content   文档内容
 * @param string $fileName 文档名称
 */
function downloadWord($content, $fileName='new_file.doc'){

    if(empty($content)){
        return;
    }

    header("Cache-Control: no-cache, must-revalidate");
    header("Pragma: no-cache");
    header("Content-Type: application/octet-stream");
    header("Content-Disposition: attachment; filename=$fileName");

    $html = '';
    $html .= '';

    echo $html . ''.$content .'';

}

你可能感兴趣的:(html生成word文档并下载)