我要做的是将excel文件作为附件通过电子邮件发送,该附件是由智能tpl文件创建的,所以目前这就是我正在做的事情:
$smarty->display('export-report.tpl');
$name=str_replace(" ","",$_POST['catname'])."_".date('d-m-Y');
Header("Content-Type: application/vnd.ms-excel");
Header("Content-Disposition: attachment; filename=".$name.".xls");
但我接下来要做的不是直接从我想要附加它的浏览器下载excel文件并将其发送到电子邮件中,为了做到这一点,我首先在我的服务器上保存文件并创建excel文件我需要excel的内容(tpl文件中包含的html)在php变量中。
所以我的问题是如何得到这个:
$smarty->display('export-report.tpl');
包含在这样的变量中:
$content
感谢。
答案 0 :(得分:0)
您需要以这种方式使用fetch
方法:
$content = $smarty->fetch('export-report.tpl');
修改强>
也许你想要的只是改变顺序:
$name=str_replace(" ","",$_POST['catname'])."_".date('d-m-Y');
header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=".$name.".xls");
$smarty->display('export-report.tpl');
或
$content = $smarty->fetch('export-report.tpl');
$name=str_replace(" ","",$_POST['catname'])."_".date('d-m-Y');
header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=".$name.".xls");
echo $content;