I got easy way to create excel file using PHP and also it will download on client pc. so let’s go for coding.
Put this two lines in top of your PHP file.
header('Content-type: application/excel'); header('Content-Disposition: attachment; filename="sample.xls"');
Content Disposition header to supply a recommended filename and force the browser to display the save dialog.
now in html body part you can put any content which you want to fill it inside excel file.