System sends a file to browser even warning happens, \moonland\phpexcel

Hi,

in my controller, I do send a file to a web browser with \moonland\phpexcel like that

\moonland\phpexcel\Excel::widget([
‘models’ => $rows,
‘fileName’ => ‘sth.xlsx’,
‘mode’ => ‘export’,
‘columns’ => array_keys($columns),
‘headers’ => $columns,
]);

If a Warning/Error happens just before the widget is used, for instance “division by 0”, the system still sends the file, but the one that has been generated during the last correct call. So it does not generate the file but still sends the old one. The real problem is that the old one could be generated by other users with their personal data.

$i=10/2;

/* the script doesn’t reach that place, at least die() put here does not work */

\moonland\phpexcel\Excel::widget([
‘models’ => $rows,
‘fileName’ => ‘sth.xlsx’,
‘mode’ => ‘export’,
‘columns’ => array_keys($columns),
‘headers’ => $columns,
]);
/* but the file is sent to the browser… */

When I replace the piece with \moonland\phpexcel\Excel::widget with manually generated csv file like that:

header(‘Content-type: text/csv’);header('Content-Disposition: attachment; filename=“sth.csv”);
echo $content;
exit();

the system does not send any file, but request ends in with 500.

I cannot figure out what is going on there. Any advice, please?