Cabecera para crear un documento excel, en este caso dinámico.
header("Content-type: application/vnd.ms-excel");tent-Disposition: attachment; filename=registros.xls");tent-type: application/x-msdownload");
header("Pragma: no-cache");
header("Expires: 0");
print "ID\t";
print "NUMERO SERIE\t";
print "SERVICE TYPE\t";
print "FECHA COMPRA\t";
print "NOMBRE/EMPRESA\t";
print "EMAIL\t";
print "DIRECCION\t";
print "CP\t";
print "POBLACION\t";
print "PROVINCIA\t";
print "TELEFONO\t";
print "FAX\t";
print "PERSONA CONTACTO\t";
print "SAP MATERIAL CODE\t";
print "TIPO\t";
print "FECHA REGISTRO\t";
print "\n";
for($a=0;$a<$cantidadRegistros;$a++){
$tipoName = ($rs[$a]['Tipo'] == 1) ? "Extensión" : "Coverplus";
print html_entity_decode($rs[$a]['id']) . "\t" . $rs[$a]['Contract_num'] . "\t" . $rs[$a]['Service_type'] . "\t" . $rs[$a]['Purchase_date'] . "\t" . html_entity_decode($rs[$a]['Customer_name']) . "\t" . $rs[$a]['Customer_email'] . "\t" . html_entity_decode($rs[$a]['Customer_address']) . "\t" . $rs[$a]['Customer_cp'] . "\t" . html_entity_decode($rs[$a]['Custormer_city']) . "\t" . codigoProvincia($rs[$a]['Customer_cp']) . "\t" . $rs[$a]['Customer_phone'] . "\t" . $rs[$a]['Customer_fax'] . "\t" . html_entity_decode($rs[$a]['Reference_person']) . "\t" . $rs[$a]['SAP_material_code'] . "\t" . $tipoName. "\t" . $rs[$a]['Fecha_reg'] . "\t" . "\n";
}

