Foros del Web » Programando para Internet » PHP »

Agregar datos al exel

Estas en el tema de Agregar datos al exel en el foro de PHP en Foros del Web. Hola, encontre este codigo en los FAQs y lo edite: Código PHP: <?php $nombre  =  $_POST [ 'nom' ]; $ape  =  $_POST [ 'ap' ]; ...
  #1 (permalink)  
Antiguo 28/01/2008, 11:36
Avatar de pato12  
Fecha de Ingreso: septiembre-2007
Ubicación: Salta
Mensajes: 1.620
Antigüedad: 16 años, 7 meses
Puntos: 101
Agregar datos al exel

Hola,
encontre este codigo en los FAQs y lo edite:
Código PHP:
<?php
$nombre 
$_POST['nom'];
$ape $_POST['ap'];
$maquina $_POST['maq'];
$problema $_POST['pro'];
$fecha strftime("%d - %m - %y"time());
$shtml="<table width='444' border='1' cellpadding='0' cellspacing='0' bordercolor='#000000'>  <tr> <td width='113' height='25' bgcolor='#FFFF99'>Nombre:</td>    <td width='325' bgcolor='#CCCCFF'>$nombre</td>  </tr>  <tr>    <td width='113' height='25' bgcolor='#FFFF99'>Apellido:</td>    <td bgcolor='#CCCCFF'>$ape</td>  </tr>  <tr>    <td width='113' height='25' bgcolor='#FFFF99'>Maquina:</td>    <td bgcolor='#CCCCFF'>$maquina</td>  </tr>  <tr>    <td height='25' bgcolor='#FFFF99'>Problema:</td>    <td bgcolor='#CCCCFF'>$problema</td>  </tr>  <tr>    <td height='25' bgcolor='#FFFF99'>Fecha entrada: </td>    <td bgcolor='#CCCCFF'>$fecha</td>  </tr>  <tr>    <td height='25' bgcolor='#FFFF99'>Fecha de salida: </td>    <td bgcolor='#CCCCFF'>&nbsp;</td>  </tr>  <tr>    <td height='25' bgcolor='#FFFF99'>Precio:</td>    <td bgcolor='#CCCCFF'>&nbsp;</td> <tr> <td height='25' bgcolor='#FFFFFF'>&nbsp;</td>    <td bgcolor='#FFFFFF'>&nbsp;</td></tr></tr></table>"
$scarpeta="carpeta/"//carpeta donde guardar el archivo. 
//debe tener permisos 775 por lo menos 
$sfile=$scarpeta."miexel.xls"//ruta del archivo a generar 
$fp=fopen($sfile,"a+"); 
fwrite($fp,$shtml); 
fclose($fp); 
header ("Location: exee.php?mensaje=0");
?>
Pero si estan usando el exel selecionado me sale error y yo quiero que no me salga el erro sino que me lleve a exee.php?mensaje=1 y es un mensaje de error.
Gracias
Salu2
__________________
Half Music - www.halfmusic.com
  #2 (permalink)  
Antiguo 28/01/2008, 12:03
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Re: Agregar datos al exel

A que te refieres con:
Cita:
Pero si estan usando el exel selecionado me sale error y yo quiero que no me salga el erro sino que me lleve a exee.php?mensaje=1 y es un mensaje de error.
¿Podrías ampliar mas tu problema?

Saludos.
  #3 (permalink)  
Antiguo 28/01/2008, 12:05
Avatar de pato12  
Fecha de Ingreso: septiembre-2007
Ubicación: Salta
Mensajes: 1.620
Antigüedad: 16 años, 7 meses
Puntos: 101
Re: Agregar datos al exel

Gracias por contestar.
Es que estaba apurado. Me quedaba poco tiempo.
Me refiero a que si no se pudo agregar los datos al exel me lleve a exee.php?mensaje=1.
Gracias
Salu2
__________________
Half Music - www.halfmusic.com
  #4 (permalink)  
Antiguo 28/01/2008, 12:36
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Re: Agregar datos al exel

Código PHP:
$result fwrite($fp,$shtml); 
fclose($fp); 
if( !
$result ) {
        
header ("Location: exee.php?mensaje=1"); 
} else {
        
header ("Location: exee.php?mensaje=0"); 

Saludos.
  #5 (permalink)  
Antiguo 28/01/2008, 12:43
Avatar de pato12  
Fecha de Ingreso: septiembre-2007
Ubicación: Salta
Mensajes: 1.620
Antigüedad: 16 años, 7 meses
Puntos: 101
Re: Agregar datos al exel

Gracias,
Despues te abiso si me anda o no ( porque despues: porque no tengo la compu que nesesito )
Salu2
__________________
Half Music - www.halfmusic.com
  #6 (permalink)  
Antiguo 28/01/2008, 15:46
Avatar de pato12  
Fecha de Ingreso: septiembre-2007
Ubicación: Salta
Mensajes: 1.620
Antigüedad: 16 años, 7 meses
Puntos: 101
Re: Agregar datos al exel

Hola no me funciona.
Cuando esta abierto el miexel.xls me tira esto:
Cita:
Warning: fopen(jojo/jojo.xls) [function.fopen]: failed to open stream: Permission denied in C:\AppServ\www\exe.php on line 11

Warning: fwrite(): supplied argument is not a valid stream resource in C:\AppServ\www\exe.php on line 12

Warning: fclose(): supplied argument is not a valid stream resource in C:\AppServ\www\exe.php on line 13

Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\exe.php:11) in C:\AppServ\www\exe.php on line 15
Salu2
__________________
Half Music - www.halfmusic.com
  #7 (permalink)  
Antiguo 28/01/2008, 16:00
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Re: Agregar datos al exel

Cambia entonces en lugar del fwrite sube la condicion:
Código PHP:
$fp=@fopen($sfile,"a+");
if( !
$fp {
      
header ("Location: exee.php?mensaje=1");

Saludos.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 14:08.