MySql Data To Excel using php

Use this code to convert your Mysql Query to Excel file

header ('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header ('Content-Disposition: attachment; filename="filename.xlsx"');
header ('Content-Transfer-Encoding: binary');
header ('Content-Length: '.$fileSize);