Posted By

freakdesign on 03/14/13


Tagged


Versions (?)

PHPExcel basic array loop


 / Published in: PHP
 

Basic usage for PHPExcel with an mysqlfetcharray

  1. <?php
  2.  
  3. $objPHPExcel = new PHPExcel();
  4. $objPHPExcel->setActiveSheetIndex(0);
  5. $rowCount = 1;
  6. while($row = mysql_fetch_array($result)){
  7. $objPHPExcel->getActiveSheet()->SetCellValue('A'.$rowCount, $row['name']);
  8. $objPHPExcel->getActiveSheet()->SetCellValue('B'.$rowCount, $row['age']);
  9. $rowCount++;
  10. }
  11. $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
  12. $objWriter->save('some_excel_file.xlsx');
  13.  
  14. ?>

Report this snippet  

You need to login to post a comment.