Yii v2 snippet guide II

Comparing #16 with #17

Revision #17 was created by rackycz rackycz on Sep 8, 2020, 7:30:00 PM.

Composer and PhpExcel

Content

[...]
// Or you can send the file directly to the browser so user can download it:
// header('Content-Type: application/vnd.ms-excel'); // This is probably for older XLS files.
header('Content-Type: application/application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); // This is for XLSX files (they are basically zip files).
header('Content-Disposition: attachment;filename="filename.xlsx"');
$writer->save('
hello_world.xlsxphp://output'); exit(); ``` Thanks to [DbCreator](https://forum.yiiframework.com/t/yii2-phpoffice-phpspreadsheet-src-phpspreadsheet-shared-ole-pps-root-php-on-line-292-headers-already-sent/126617) for the latter approach. Other ways did not work for me.