Cześć, pisze właśnie skrypt który eksportuje mi dane z bazy danych do pliku excel.
<?php
require_once("database.php");
$records = $conn->prepare("SELECT * FROM users");
$records->execute();
$output = '';
if($records->rowCount() > 0)
{
$output .= '<table><thead><tr><th>Id</th><th>first_name</th><th>last_name</th><th>email</th><th>city</th><th>avatar</th></tr></thead><tbody>';
while($results = $records->fetch(PDO::FETCH_OBJ))
{
$output .= '
<tr>
<td>'.$results->id.'</td>
<td>'.$results->first_name.'</td>
<td>'.$results->last_name.'</td>
<td>'.$results->email.'</td>
<td>'.$results->city.'</td>
<td>'.$results->avatar.'</td>
</tr>';
}
$output .= '</tbody></table>';
header('Content-Type: application/xls');
header('Content-Disposition: attachment; filename=LiveSearch.xls');
echo $output;
}
?>
Problem jest taki że po pobraniu pliku i uruchomieniu go w excel'u pokazuje się błąd o błędny formacie
Po kliknięciu tak dane są wyświetlone jednak dość dziwnie nie jak w excel normalnie
I brakuje polski znaków
Pytanie teraz czy wie ktoś jak to naprawić ? aby dane wyświetlały się w 100% poprawnie.
- export results.png (57 KB) - ściągnięć: 148
- export komunikat.png (8 KB) - ściągnięć: 106