How to Export XLS file in PHP:
SOlution:
$date_format = 'n/j/Y g:i:s A'; while(@ob_end_clean()); require_once(dirname(__FILE__).'/RecipeExcelWriter.class.php'); $xls = new RecipeExcelWriter(); $xls->addRow(array( 'Recipe ID', 'Recipe Name', 'Chef Name', 'Dishtype', 'Status', 'Date Added', 'Date Updated ', 'Utensils', 'Ingredients', 'Video', )); foreach($items as $item){ if($feu->MemberOfGroup($item['user_id'],$feu->GetGroupID($this->GetPreference('feu_group')))) $status = 'Chef'; elseif($feu->MemberOfGroup($item['user_id'],$feu->GetGroupID('New Users'))) $status = 'New User'; else $status = '(none)'; if($item.recipe_status == 0){ $Recipestatus = 'In Progress'; }else if($item.recipe_status == 1){ $Recipestatus = 'Submitted'; }else if($item.recipe_status == 2){ $Recipestatus = 'Approved'; }else if($item.recipe_status == 3){ $Recipestatus = 'Published'; } $ingredient = $this->getIngredients($item['recipe_id']); $utensils = $this->getUtensils($item['recipe_id']); $ing_title = ''; $utensil_title = ''; foreach($ingredient as $ing){ $ing_title .= $ing['title']; } foreach($utensils as $uten){ $utensil_title .= $uten; } if($this->getVideo($item['recipe_id'])) $Indicator = 'Yes'; else $Indicator = 'No'; $xls->addRow(array( $item['recipe_id'],$item['recipe_title'], $feu->GetUserPropertyFull('first_name',$item['user_id'],$item['user_id']).' '.$feu->GetUserPropertyFull('last_name',$item['user_id'],$item['user_id']), str_replace('\'','\\\'',$this->getMultipleCategory($this->getRecipeCategory($item['recipe_id'],'dishtype'),true)), /*str_replace('\'','\\\'',$this->getCategory($this->getRecipeCategory($item['recipe_id'],'mainingredient'),true)), str_replace('\'','\\\'',$this->getCategory($this->getRecipeCategory($item['recipe_id'],'dishtype'),true)),*/ $Recipestatus, date($date_format,strtotime($item['recipe_added'])), date($date_format,strtotime($item['recipe_updated'])), $utensil_title, $ing_title, $Indicator, )); } $xls->send('chefs.'.date('Y-m-d.Hi')); exit; <strong>Class file for export XLS file (RecipeExcelWriter.class.php'):</strong> data .= " <tr>\n"; foreach($line_arr as $value) $this->data .= " <td class="xl24" width="64">{$value}</td>\n"; $this->data .= " </tr>\n"; } function send($filename = null){ //print_r($_REQUEST);exit; if($filename){ header ( "Expires: Mon, 1 Apr 1974 05:00:00 GMT" ); header ( "Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT" ); header ( "Pragma: no-cache" ); //if($_REQUEST['m1_recipe_xls'] == 1){ header ( "Content-type: application/x-msexcel" ); header ( "Content-Disposition: attachment; filename={$filename}.xls" ); /*}else{ header('Content-type: application/octet-stream'); header('Content-Disposition: attachment; filename="filename.csv"'); }*/ } }
This is really interesting, You’re a very skilled blogger. I’ve joined your rss feed and look forward to seeking more of your excellent post. Also, I have shared your website in my social networks!
It was extremely interesting for me to read the post. Thanks for it. I like such topics and everything that is connected to this matter. I would like to read a bit more on that blog soon.
Hilary Smith
portable cell jammer
Oh! thax a lot for appreciation..i would like to SERVE some more helpful information soon..
Chandresh.
Rather interesting place you’ve got here. Thanx for it. I like such topics and anything connected to this matter. I definitely want to read more soon.
Avril Hakkinen
agency escort
Thank you very much…..:)
Wow, indeed interesting information. How can I find this RSS?
Kate Stone
escort services new york
hi,yes i m trying to give this facility to my all users. i’ll do within some days..
Thanks for support.
And what about adding some more images? No offence, blog is really great. Just as I know people acquire information much more efficient if there are certain useful images.
Nency Tayfon
phone jam
ok..i m little bit busy so cant find time for more explanation.but will try for next time.
Thanks.!