alterações 07-04-26
This commit is contained in:
28
lista/gerar_excel.php
Executable file
28
lista/gerar_excel.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?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>";
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user