I understand that your solution is the best if you just want to export some data but not good enough to generate a full report
However you can generated table with multiple rows an column in html its totally upto you how much data you want it table it just export the content of html table
you can see the below code
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=predefined_wip_report.xls");
header("Content-Type: application/vnd.ms-excel");
echo '<table>';
echo $text = $_REQUEST['tbodyContent'];
echo "</table>";
where $_REQUEST['tbodyContent'] brings the content of the table