Showing posts with label generating. Show all posts
Showing posts with label generating. Show all posts

Thursday, July 4, 2013

How To Generate EXCEL Files With PHP

Today, I will share a very useful application with you guys, generating excel files with using PHP. As you know, we need reports as excel, pdf, word etc. in our web sites. For that reason, generating all of'em is important thing for us. Some of us use basic HTML files with using PHP & a data base. But this is not enough. Thus, I use generating excel.
So, Let's code :)
$filename = "myExcelFile_".date('Y-m-d-h-i').".xls"; 

header("Content-Disposition: attachment; 

header("Content-Type: application/"); 

header('Content-Type: application/x-msexcel; 
        charset=UTF-8; format=attachment;');

echo "\tMy EXCEL DATA\r\n"; 


I set my file name up as myExcelFile_ plus current time and some header configuration. Then finally I print. That's it.
If you run, you'll see this view:

This article was short but so useful. You can develop better, of course.
See you next article.