I have used the code below to generate a report in excel:
require_once "phpexcel/class.writeexcel_workbook.inc.php";
require_once "phpexcel/class.writeexcel_worksheet.inc.php";
$fname = tempnam("/tmp", "simple.xls");
$workbook = &new writeexcel_workbook($fname);
$gen =& $workbook->addformat();
$gen->set_align('left');
$gen->set_num_format('General');
$worksheet = &$workbook->addworksheet("records");
$worksheet->write_string(0,0,'Customer');
$worksheet->write_string(0,1,'ID');
$worksheet->set_column(0,0,30,$gen);
$worksheet->set_column(0,1,10,$gen);
$j=1;
while($res = mysql_fetch_array($qry))
{
$worksheet->write($j,0,$res['cust']);
$worksheet->write($j,1,$res['id']);
$j++;
}
$workbook->close();
header("Content-Type: application/x-msexcel; name=records.xls");
header("Content-Disposition: inline; filename=records.xls");
When I run this file its generating output correctly but only the problem is if my records comes above 24000 then it shows an error message.
if I set 1 to 24000 records its working
if I set above 24000 records its working
if I set all then its not working (at the time 26000 records will come)