Ver Mensaje Individual
  #5 (permalink)  
Antiguo 09/02/2009, 15:20
Avatar de SCY-FOX
SCY-FOX
 
Fecha de Ingreso: septiembre-2007
Ubicación: Chile
Mensajes: 139
Antigüedad: 16 años, 7 meses
Puntos: 5
Respuesta: Headers! Fastidiosos Headers!

Cambia a esto:

Código PHP:
<?php require_once('Connections/Myconection.php'); ?>
<?php session_start
(); 

mysql_select_db($database_Myconection$Myconection);

header("Content-type: application/vnd-ms-excel; charset=iso-8859-1");
header("Content-Disposition: attachment; filename=NombreDelExcel_".date('d-m-Y').".xls");


$sql "SELECT clientes.nombre,  preguntas.indicador, preguntas.tipo, preguntas.ask, puntaje.observaciones, puntaje.suma, puntaje.puntos
FROM clientes, preguntas, puntaje
WHERE puntaje.cliente=clientes.nit AND puntaje.pregunta=preguntas.id_pr  AND preguntas.iden=19"
;
$r =  mysql_query($sql) or trigger_error(mysql_error($Myconection),E_USER_ERROR); 
$return '';
if( 
mysql_num_rows($r)>0){
    
$return .= '<table border=1>';
    
$cols 0;
    while(
$rs mysql_fetch_row($r)){
        
$return .= '<tr>';
        if(
$cols==0){
            
$cols sizeof($rs);
            
$cols_names = array();
            for(
$i=0$i<$cols$i++){
                
$col_name mysql_field_name($r,$i);
                
$return .= '<th>'.htmlspecialchars($col_name).'</th>';
                
$cols_names[$i] = $col_name;
            }
            
$return .= '</tr><tr>';
        }
        for(
$i=0$i<$cols$i++){
            if(
$cols_names[$i] == 'fechaAlta'){ #Fromateo el registro en formato Timestamp
                
$return .= '<td>'.htmlspecialchars(date('d/m/Y H:i:s',$rs[$i])).'</td>';
            }else if(
$cols_names[$i] == 'activo'){ #Estado lógico del registro, en vez de 1 o 0 le muestro Si o No.
                
$return .= '<td>'.htmlspecialchars$rs[$i]==1'SI':'NO' ).'</td>';
            }else{
                
$return .= '<td>'.htmlspecialchars($rs[$i]).'</td>';
            }
        }
        
$return .= '</tr>';
    }
    
$return .= '</table>';
    
mysql_free_result($r);
}

?>

<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
</head>
<body>
<?=$return;?>
</body>
</html>