Thursday, 15 August 2013

excel - how to contain a *.tpl file in a php variable? -



excel - how to contain a *.tpl file in a php variable? -

what i'm trying email excel file attachment that's created out of smarty tpl file, i'm doing:

$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");

but want next instead of downloading excel file straight browser want attach , send in email, in order saving file first on server , create excel file need content of excel (the html contained in tpl file) within php variable.

so question how this:

$smarty->display('export-report.tpl');

to contained in variable this:

$content

thanks.

you need utilize fetch method way:

$content = $smarty->fetch('export-report.tpl');

edit

maybe want changing order way:

$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');

or

$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;

php excel smarty

No comments:

Post a Comment