Closed allweDepth closed 1 year ago
fix with MAMP packaged by Bitnami php 8.1.11. I do not know why
I have the same problem. Just need to clear the output buffer before sending HTTP header.
// clear output buffer
ob_end_clean();
header('Content-disposition: attachment; filename="'.rawurlencode($filename).'"; filename*=utf-8\'\''.rawurlencode($filename));
header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
header('Cache-Control: max-age=0');
header('Pragma: public');
$writer->writeToStdOut();
I would suggest to add the header output and clear buffer into the writeToStdOut() and change it to:
public function writeToStdOut($filename)
{
$temp_file = $this->tempFilename();
self::writeToFile($temp_file);
// Clear any previous output (otherwise the generated file will be corrupted)
ob_end_clean();
header('Content-disposition: attachment; filename="'.rawurlencode($filename).'"; filename*=utf-8\'\''.rawurlencode($filename));
header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
eader("Content-Length: ".filesize($temp_file));
header('Cache-Control: max-age=0');
header('Pragma: public');
readfile($temp_file);
}
Thanks respon @alex-twbsd i Will try your note🙏🏻
I am try to Xampp 8.16 php version 8.1.6 and doesn't work all