&1"); $arquivo = "cadastros.xlsx"; if (file_exists($arquivo)) { // Definir headers para o download do arquivo header('Content-Description: File Transfer'); header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition: attachment; filename="' . basename($arquivo) . '"'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($arquivo)); // Ler e enviar o arquivo readfile($arquivo); // Remover o arquivo temporário após o download (opcional) // unlink($arquivo); exit; } else { echo "Erro ao gerar o arquivo. Saída do log:
$output"; } ?>