How to export data to an excel file using PHPExcel

后端 未结 5 974
迷失自我
迷失自我 2020-12-02 21:01

I have taken the source code from limesurvey and have added the PHPExcel library to my limesurvey code to export data to an excel file after you click a link. Currently the

5条回答
  •  不知归路
    2020-12-02 21:26

    Try the below complete example for the same

    getActiveSheet();
      foreach($sheet as $row => $columns) {
        foreach($columns as $column => $data) {
            $worksheet->setCellValueByColumnAndRow($column, $row + 1, $data);
        }
      }
    
      //make first row bold
      $objPHPExcel->getActiveSheet()->getStyle("A1:I1")->getFont()->setBold(true);
      $objPHPExcel->setActiveSheetIndex(0);
      $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
      $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
    ?>
    

提交回复
热议问题