Files
quiz-ius/lista/gerar_excel.php
2026-04-07 20:46:59 +00:00

28 lines
884 B
PHP
Executable File

<?php
// lista/gerar_excel.php
// Executa o script Python para gerar a planilha
$output = shell_exec("python3 converterTabelaEmPlanilha.py 2>&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: <pre>$output</pre>";
}
?>