PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, October 4, 2022

[FIXED] How to integrate PHPExcel in Yii2 Framework?

 October 04, 2022     php, phpexcel, yii2     No comments   

Issue

I want to capture html form fields data and save it in a .xlsx file. I looked around and found PHPExcel but couldn't figure out how to integrate it to Yii2. Can someone tell me how to integerate. I want to use something like this in my controller:

require('../PHPExcel.php');
$objPHPExcel = new PHPExcel;
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel,  "Excel2007");
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="file.xlsx"');
header('Cache-Control: max-age=0');
$objWriter->save('php://output');`

Solution

Add PHPExcel to the project using composer. Then refers to it using @vendor prefix in require('@vendor/...') to reach specific package



Answered By - Ben
Answer Checked By - Clifford M. (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing