Ver Mensaje Individual
  #1 (permalink)  
Antiguo 30/03/2012, 12:37
chumy_
 
Fecha de Ingreso: noviembre-2011
Mensajes: 121
Antigüedad: 12 años, 5 meses
Puntos: 0
problema en exportacion a excel

Hola... tengo un problema al exportar una tabla dinamica con datos mysql hacia excel. Especificamente el cuando tengo datos tipo "1-2" o "01-02" excel me lo transforma en fecha "1-feb", y asi con cualquier dato que pueda ser transformado en tabla... como puedo hacer para que no me suceda esto???

dejo el codigo por cualquier cosa..

Código PHP:
<?php require_once('Connections/localhost.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  if (
PHP_VERSION 6) {
    
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
}

$colname_Recordset1 "-1";
if (isset(
$_GET['noper'])) {
  
$colname_Recordset1 $_GET['noper'];
}
mysql_select_db($database_localhost$localhost);
$query_Recordset1 sprintf("SELECT * FROM cert_validado WHERE cod_proy = %s"GetSQLValueString($colname_Recordset1"text"));
$Recordset1 mysql_query($query_Recordset1$localhost) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);
?>

<?php
$fecha 
date('d-m-Y');

header('Content-type: application/vnd.ms-excel');
header("Content-Disposition: attachment; filename=Mantenciones_realizadas_al_".$fecha.".xls");
header("Pragma: no-cache");
header("Expires: 0");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
</head>
<body>
<table border="0">
  <tr>
    <td>ncert</td>
    <td>Fecha</td>
    <td>hora</td>
    <td>rut</td>
    <td>tecnico</td>
    <td>proyecto</td>
    <td>poblacion</td>
    <td>calle</td>
    <td>pisos</td>
    <td>morador</td>
    <td>tipo_gas</td>
    <td>empresa</td>
    <td>artefacto</td>
    <td>tipo_artefacto</td>
    <td>marca</td>
    <td>modelo</td>
    <td>n_serie</td>
    <td>potencia</td>
    <td>ubicacion</td>
    <td>volumen</td>
    <td>encendido</td>
    <td>con_gas</td>
    <td>con_agua</td>
    <td>comandos</td>
    <td>quemadores</td>
    <td>conducto_2</td>
    <td>sellac2_uni</td>
    <td>diseno_mat_c2</td>
    <td>carcasa</td>
    <td>conjunto_piloto</td>
    <td>inter_calor</td>
    <td>sist_seguridad</td>
    <td>co_corr_ppc_antes</td>
    <td>co_corr_ppc_despues</td>
    <td>co_amb_ppm_antes</td>
    <td>co_amb_ppm_despues</td>
    <td>tiro_antes</td>
    <td>tiro_despues</td>
    <td>cau_agua_f_antes</td>
    <td>cau_agua_f_despues</td>
    <td>t_agua_f_antes</td>
    <td>t_agua_f_despues</td>
    <td>cau_agua_t_antes</td>
    <td>cau_agua_t_despues</td>
    <td>t_agua_t_antes</td>
    <td>t_agua_t_despues</td>
    <td>valvula_gas</td>
    <td>valvula_agua</td>
    <td>sensor_revoco</td>
    <td>sensor_temp</td>
    <td>bobina</td>
    <td>red_gas</td>
    <td>artefactos</td>
    <td>observaciones</td>
    <td>nombre</td>
    <td>rut1</td>
    <td>cod_ver</td>
    <td>tel_fijo</td>
    <td>tel_celular</td>
    <td>correo</td>
    <td>obs_de_recep</td>
    <td>fecha_validacion</td>
    <td>hora_validacion</td>
    <td>validado</td>
    <td>obs_validacion</td>
    <td>estado</td>
    <td>estanqueidad</td>
  </tr>
  <?php do { ?>
    <tr>
      <td><?php echo $row_Recordset1['ncert']; ?></td>
      <td><?php echo $row_Recordset1['Fecha']; ?></td>
      <td><?php echo $row_Recordset1['hora']; ?></td>
      <td><?php echo $row_Recordset1['rut']; ?></td>
      <td><?php echo $row_Recordset1['tecnico']; ?></td>
      <td><?php echo $row_Recordset1['proyecto']; ?> - <?php echo $row_Recordset1['cod_proy']; ?></td>
      <td><?php echo $row_Recordset1['poblacion']; ?></td>
      <td><?php echo $row_Recordset1['calle']; ?> - <?php echo $row_Recordset1['n']; ?> - <?php echo $row_Recordset1['tipo_recinto']; ?> - <?php echo $row_Recordset1['n1']; ?></td>
      <td><?php echo $row_Recordset1['pisos']; ?></td>
      <td><?php echo $row_Recordset1['morador']; ?></td>
      <td><?php echo $row_Recordset1['tipo_gas']; ?></td>
      <td><?php echo $row_Recordset1['empresa']; ?></td>
      <td><?php echo $row_Recordset1['artefacto']; ?></td>
      <td><?php echo $row_Recordset1['tipo_artefacto']; ?></td>
      <td><?php echo $row_Recordset1['marca']; ?></td>
      <td><?php echo $row_Recordset1['modelo']; ?></td>
      <td><?php echo $row_Recordset1['n_serie']; ?></td>
      <td><?php echo $row_Recordset1['potencia']; ?></td>
      <td><?php echo $row_Recordset1['ubicacion']; ?></td>
      <td><?php echo $row_Recordset1['volumen']; ?></td>
      <td><?php echo $row_Recordset1['encendido']; ?></td>
      <td><?php echo $row_Recordset1['con_gas']; ?></td>
      <td><?php echo $row_Recordset1['con_agua']; ?></td>
      <td><?php echo $row_Recordset1['comandos']; ?></td>
      <td><?php echo $row_Recordset1['quemadores']; ?></td>
      <td><?php echo $row_Recordset1['conducto_2']; ?></td>
      <td><?php echo $row_Recordset1['sellac2_uni']; ?></td>
      <td><?php echo $row_Recordset1['diseno_mat_c2']; ?></td>
      <td><?php echo $row_Recordset1['carcasa']; ?></td>
      <td><?php echo $row_Recordset1['conjunto_piloto']; ?></td>
      <td><?php echo $row_Recordset1['inter_calor']; ?></td>
      <td><?php echo $row_Recordset1['sist_seguridad']; ?></td>
      <td><?php echo $row_Recordset1['co_corr_ppc_antes']; ?></td>
      <td><?php echo $row_Recordset1['co_corr_ppc_despues']; ?></td>
      <td><?php echo $row_Recordset1['co_amb_ppm_antes']; ?></td>
      <td><?php echo $row_Recordset1['co_amb_ppm_despues']; ?></td>
      <td><?php echo $row_Recordset1['tiro_antes']; ?></td>
      <td><?php echo $row_Recordset1['tiro_despues']; ?></td>
      <td><?php echo $row_Recordset1['cau_agua_f_antes']; ?></td>
      <td><?php echo $row_Recordset1['cau_agua_f_despues']; ?></td>
      <td><?php echo $row_Recordset1['t_agua_f_antes']; ?></td>
      <td><?php echo $row_Recordset1['t_agua_f_despues']; ?></td>
      <td><?php echo $row_Recordset1['cau_agua_t_antes']; ?></td>
      <td><?php echo $row_Recordset1['cau_agua_t_despues']; ?></td>
      <td><?php echo $row_Recordset1['t_agua_t_antes']; ?></td>
      <td><?php echo $row_Recordset1['t_agua_t_despues']; ?></td>
      <td><?php echo $row_Recordset1['valvula_gas']; ?></td>
      <td><?php echo $row_Recordset1['valvula_agua']; ?></td>
      <td><?php echo $row_Recordset1['sensor_revoco']; ?></td>
      <td><?php echo $row_Recordset1['sensor_temp']; ?></td>
      <td><?php echo $row_Recordset1['bobina']; ?></td>
      <td><?php echo $row_Recordset1['red_gas']; ?></td>
      <td><?php echo $row_Recordset1['artefactos']; ?></td>
      <td><?php echo $row_Recordset1['observaciones']; ?></td>
      <td><?php echo $row_Recordset1['nombre']; ?></td>
      <td><?php echo $row_Recordset1['rut1']; ?></td>
      <td><?php echo $row_Recordset1['cod_ver']; ?></td>
      <td><?php echo $row_Recordset1['tel_fijo']; ?></td>
      <td><?php echo $row_Recordset1['tel_celular']; ?></td>
      <td><?php echo $row_Recordset1['correo']; ?></td>
      <td><?php echo $row_Recordset1['obs_de_recep']; ?></td>
      <td><?php echo $row_Recordset1['fecha_validacion']; ?></td>
      <td><?php echo $row_Recordset1['hora_validacion']; ?></td>
      <td><?php echo $row_Recordset1['validado']; ?></td>
      <td><?php echo $row_Recordset1['obs_validacion']; ?></td>
      <td><?php echo $row_Recordset1['estado']; ?></td>
      <td><?php echo $row_Recordset1['estanqueidad']; ?></td>
    </tr>
    <?php } while ($row_Recordset1 mysql_fetch_assoc($Recordset1)); ?>
</table>
</body>
</html>
<?php
mysql_free_result
($Recordset1);
?>
Gracias ;)