如何使用PHP将数据库传递给excel?

What I am trying to do is pass my database to excel. This is what I have so far:

$contents = "Nombre, Dirrecion, Telefono, Categoria, Correo
";

$query = "SELECT datos.list, datos.addr, datos.tel, datos.cat, mail.mail FROM datos RIGHT JOIN mail ON datos.id = mail.id";

$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_array($result)){
  if(!empty($row['list'])){
    $contents.=$row['list'].",";
    $contents.=$row['addr'].",";
    $contents.=$row['tel'].",";
    $contents.=$row['cat'].",";
    $contents.=$row['mail']."
";
  }
}
$contents = strip_tags($contents);

Header("Content-Disposition: attachment; filename='excExport".date('d-m-Y').".csv'");
print $contents;

It prints out the contents correctly, when I try to open excExport.csv I can't seem to find this file in my computer.

Windows uses a combination of and for a new line so instead of use .

Example: $contents = "Nombre, Dirrecion, Telefono, Categoria, Correo ";

Check out this link: , , what is the difference between them?

P.S. I'm assuming this is for windows because your using Excell, this won't work in other situations.