-1

I'm working on a Yii2 rest Api that's connected to AngularJS front end.

I'm trying to build an actionDownloadAsExcel method that can help me download a specific model. What would be a good way to do this?

I installed "phpOffice\phpExcel" but I don't really know how to use it for my purpose.

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Andrs888
  • 21
  • 4
  • I suggest you read **[How to ask perfect question](https://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/)** and edit your question accordingly. – Marcin Orlowski May 05 '17 at 13:31

1 Answers1

0

You can find all the data you want to save to the excel, print that using an html table and setting a proper excel header before the view is rendered:

header("Content-Type:   application/vnd.ms-excel; charset=utf-8");
header("Content-Disposition: attachment; filename=abc.xls");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);

Source: PHP Excel Header

Community
  • 1
  • 1
Chux
  • 1,196
  • 1
  • 9
  • 24