bom dia
Estou gerando um relatório em php e mysql para excel e o relatório gera tudo certo, mas na hora de abrir o arquivo Excel (xls) ele aparece uma mensagem que o aquivo pode estar corrompido mais se clicar na opção sim ele abre o arquivo normalmente, como que faço para não exibir essa mensagem?
<?php
include_once('../db_functions.php');
$con = dbConnect();
?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<title>Logs_de_Acesso</title>
<head>
<body>
<?php
$arquivo = 'Logs_de_Acesso.xls';
$tabela = '<table border="1">';
$tabela .= '<tr>';
$tabela .= '<td colspan="6"><b><center>LOGS DE ACESSO - PORTAL CIRURGIAS RDV</center></b></td>';
$tabela .= '</tr>';
$tabela .= '<tr>';
$tabela .= '<td><b>Id</b></td>';
$tabela .= '<td><b>Host</b></td>';
$tabela .= '<td><b>Ip</b></td>';
$tabela .= '<td><b>Usuario_Nome</b></td>';
$tabela .= '<td><b>Usuario_Papel</b></td>';
$tabela .= '<td><b>Data_Evento</b></td>';
$tabela .= '</tr>';
function ConverteData($Data){
if (strstr($Data, "/"))//verifica se tem a barra /
{
$d = explode ("/", $Data);//tira a barra
$rstData = "$d[2]-$d[1]-$d[0]";//separa as datas $d[2] = ano $d[1] = mes etc...
return $rstData;
} elseif(strstr($Data, "-")){
$d = explode ("-", $Data);
$rstData = "$d[2]/$d[1]/$d[0]";
return $rstData;
}else{
return "Data invalida";
}
}
$data = ConverteData($_POST["data"]);
$dataf = ConverteData($_POST["dataf"]);
$sql = "SELECT * from activity_log_sql where data_evento >= '$data' and data_evento <= '$dataf' ORDER BY data_evento";
$query = mysqli_query($con, $sql);
while($dados = mysqli_fetch_assoc($query)){
$tabela .= '<tr>';
$tabela .= '<td>'.$dados['id'].'</td>';
$tabela .= '<td>'.$dados['host'].'</td>';
$tabela .= '<td>'.$dados['ip'].'</td>';
$tabela .= '<td>'.$dados['usuario_nome'].'</td>';
$tabela .= '<td>'.$dados['usuario_papel'].'</td>';
$tabela .= '<td>'.$dados['data_evento'].'</td>';
$tabela .= '</tr>';
}
$tabela .= '</table>';
// Força o Download do Arquivo Gerado
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header ("Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT");
header ("Cache-Control: no-cache, must-revalidate");
header ("Pragma: no-cache");
header ("Content-type: application/x-msexcel");
header ("Content-Disposition: attachment; filename={$arquivo}", date( 'dmY-His' ) );
header ("Content-Description: PHP Generated Data" );
echo $tabela;
exit;
?>
</body>
</html>