PHPExcel taking too long to write

Topics: Developer Forum
Oct 21, 2014 at 12:49 PM
Hi guys, so what I have is a tool that writes stuff from my database into a csv file. It's taking much longer than I want it to (like 30 minutes) and i'm not sure why. This is my code.
$row =2;
$objPHPExcel2->getActiveSheet()->SetCellValue('A1', 'Business Name');
$objPHPExcel2->getActiveSheet()->SetCellValue('B1', 'Phone Number');
$objPHPExcel2->getActiveSheet()->SetCellValue('C1', 'ID Number');
$objPHPExcel2->getActiveSheet()->SetCellValue('D1', 'Link');
$objPHPExcel2->getActiveSheet()->SetCellValue('E1', 'Priority');

$j = 0;
$counter = 0;
foreach($results2 as $i){
$keyid = getmultiplekeyid($category);

array_push($phonelist, getmultiplephonenumberlist($keyid[$counter]));
$linklist = getmultiplelinklist($phonelist[$counter]);
array_push($idlist, getmultipleidlist($phonelist[$counter]));

foreach($linklist as $key => $value){
$objPHPExcel2->getActiveSheet()->SetCellValue('A'.$row, $i);
$objPHPExcel2->getActiveSheet()->SetCellValue('B'.$row, $phonelist[$counter]);
$objPHPExcel2->getActiveSheet()->SetCellValue('C'.$row, $idlist[$counter]);
$objPHPExcel2->getActiveSheet()->SetCellValue('D'.$row, $key);
$objPHPExcel2->getActiveSheet()->SetCellValue('E'.$row, $value);
$row ++;
$counter ++;

// Rename sheet

Any help would be nice, thanks!
Oct 21, 2014 at 3:55 PM
If all you want to do is write to a csv file, then you're better off using PHP's built-in fputcsv() function