How to improve the speed of processing time?

Topics: Developer Forum, Project Management Forum, User Forum
Jun 25, 2012 at 9:05 AM
Edited Jun 25, 2012 at 9:10 AM

My English is poor, please forgive me.

I'm try to use the PHPExcelWriter to export data from MYSQL server. And I record the processing time.

1) 958 rows * 47 cols = 45026 cells (20s)

2) 2488 rows * 50 cols = 124400 cells  (3m) 

3) 3584 rows * 50 cols = 179200 cells (5m)

4) 10000 rows * 50 cols = 500000 cells (40m)

More cells are need to more time. But also more inefficiency. Why?
e.g.  The processing time should be...
2) (124400/45026) * 20s = 55s 
3) (179200/124400) * 3m = 4.3m
4) (500000/179200)  * 5m = 14m 

Is my code have problems?

 

$objPHPExcel = new PHPExcel();
$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
$objPHPExcel->setActiveSheetIndex(0);
$query = "SELECT * FROM exceltest;			
if ($sysDb->query($query))
{	
  $rowNumber = 2; 
  while ($row = $sysDb->fetch_row()) 
  { 
    $col = 0; 
    foreach($row as $cell) 
    { 				     
      $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $rowNumber, $cell); 
      $col++; 
    } 
    $rowNumber++; 
  }
}				
$sysDb->free_result();	
$filename="export.xls";
$objWriter->save($filename);

Thanks!!

Coordinator
Jun 25, 2012 at 5:22 PM

Try using the fromArray method to set cell values for the whole row in one go rather than looping through setting each cell individually

That will help to a degree

Jun 27, 2012 at 3:52 AM

MarkBaker,

Thank you for your reply.

Please let me know where have fromArray example?

Ray