K
K
Kurper2019-02-01 14:40:20
Yii
Kurper, 2019-02-01 14:40:20

How to make a scheduled export of an excel file to the server?

Hello.
I use PHPOffice / PhpSpreadsheet to generate excel, everything works, by pressing the "export" button, I save the file where it is convenient for me. There was a need to save it on the server according to the schedule, for example, at the beginning of each month, I can’t figure out how to do this. Who can faced such task?
Now I save like this:

...
$writer = new Xlsx($spreadsheet);
$filename = 'name.xlsx';

header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="'. $filename .'.xlsx"');
header('Cache-Control: max-age=0');

$writer->save($filename);
exit;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
coderisimo, 2019-02-01
@Kurper

Why not use cron ?
https://habr.com/ru/post/255245/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question