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->setActiveSheetIndex(0);
$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){
set_time_limit(0);
$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

$objPHPExcel2->getActiveSheet()->setTitle("Testing_Results");
        
Any help would be nice, thanks!
Coordinator
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