Problem when exporting data to Excel

Asked

Viewed 317 times

1

I have a problem when exporting the data to Excel, the number fields of the residence and misinterpreted by EXCEL

Example: if the client puts in the Number field of the residence 100 A, goes normal, more if he puts below 24, type 23 A, EXCEL interprets this as time and puts 23:00:00

The same thing happens if the client puts this way 8-10, which corresponds to Block 8 Ap 10, EXCEL interprets as date, 08/10/2016

I have already put the complement field, but it is no use, the client still puts information in the number field, I limited the number field only to numbers, then the client puts the same thing in the complement field, and gives me the same error! :(

In the database records everything right, only the dick when exporting.

I didn’t want to migrate to the Phpexcel class, but I think if there’s no way I’ll have to deploy, but I don’t know if this will solve!

This and the code to generate XML

    for($i=0;$i<1;$i++){   
    $html[$i] .= "<table>";
    $html[$i] .= "<tr>";
    $html[$i] .= "<td><b>Nome</b></td>";
    $html[$i] .= "<td><b>Email</b></td>";
    $html[$i] .= "<td><b>CPF</b></td>";
    $html[$i] .= "<td><b>Cep</b></td>";
    $html[$i] .= "<td><b>Endereço</b></td>";
    $html[$i] .= "<td><b>Numero</b></td>";
    $html[$i] .= "<td><b>Complemento</b></td>";
    $html[$i] .= "<td><b>Bairro</b></td>";
    $html[$i] .= "<td><b>Cidade</b></td>";
    $html[$i] .= "<td><b>UF</b></td>";
    $html[$i] .= "<td><b>Status do cliente</b></td>";
    $html[$i] .= "</tr>";
    $html[$i] .= "</table>";
}

$i = 1;

    $html[$i] .= "<table>";
    $html[$i] .= "<tr>";
    $html[$i] .= "<td>$nome_cad_cod</td>";
    $html[$i] .= "<td>$email_cad</td>";
    $html[$i] .= "<td>$cpf_cad</td>";   
    $html[$i] .= "<td>$cep_cad</td>";
    $html[$i] .= "<td>$endereco_cad</td>";
    $html[$i] .= "<td>$numero_cad</td>";    
    $html[$i] .= "<td>$complemento_cad</td>";
    $html[$i] .= "<td>$bairro_cad</td>";
    $html[$i] .= "<td>$cidade_cad</td>";    
    $html[$i] .= "<td>$estado_cad</td>";
    $html[$i] .= "<td>Pagseguro</td>";
    $html[$i] .= "</tr>";
    $html[$i] .= "</table>";
    $i++;
}
$arquivo = 'relatorio.xls';
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}" );
header ("Content-Description: PHP Generated Data" );

for($i=0;$i<=$result->num_rows;$i++){  
    echo $html[$i];
}
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.