PHP导出到xls,数据不完整

I have a smarty template that generates a table with 19 columns and over 7000+ rows. I then use header() options to save it out to xls. The problem is that only half the data gets into the file. If I display the table on the browser, I do see all 7000+ rows of data. I'm running my own server so I am able to set all the PHP limits like:

ini_set('max-execution_time', 0);
ini_set('memory_limit', -1);

Here's how I'm saving out the page: (I have assigned the data to $smarty)

header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=output.xls");
$smarty->display("export_file.tpl");

I've even just tried not using my data at all and just created a for loop of size 10000 inside the template file and it could only write up about 4268 rows. From playing around with the number of rows and columns, it seems to stop at around 80000 cells...

Any suggestions on how I can save out all my data?