28 lines
884 B
PHP
Executable File
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>";
|
|
}
|
|
?>
|