Ver Mensaje Individual
  #1 (permalink)  
Antiguo 31/07/2008, 23:15
macoacero
 
Fecha de Ingreso: julio-2008
Mensajes: 9
Antigüedad: 15 años, 9 meses
Puntos: 0
Ayuda excel generado desde php

Hola

Tengo un formulario en flash que genera un excel y lo envia por correo a traves de un PHP. El problema es que el archivo excel genrado es una simple lista de variables y necesito que llegue organizado en columnas y filas.

Este es el php que estoty utilizando. Le agradezco a quien tenga alguna idea:


<?PHP
$archivo = fopen("formulario.csv" , "w");
if ($archivo) {

//variables que hayamos declarado en la pelicula de flash
$datos="ciudad: $_POST[ciudad]
+ dia: $_POST[dia]
+ mes: $_POST[mes]
+ año: $_POST[anio]
+ cotizacion No: $_POST[cotizacion]

+ descripcion1: $_POST[descripcion1]
+ dias1: $_POST[dias1]
+ cantidad1: $_POST[cantidad1]
+ vr_unitario1: $_POST[vr_unitario1]
+ vr_total1: $_POST[vr_total1]

+ descripcion2: $_POST[descripcion2]
+ dias2: $_POST[dias2]
+ cantidad2: $_POST[cantidad2]
+ vr_unitario2: $_POST[cantidad2]
+ vr_total2: $_POST[vr_total2]

+ descripcion3: $_POST[descripcion3]
+ dias3: $_POST[dias3]
+ cantidad3: $_POST[cantidad3]
+ vr_unitario3: $_POST[vr_unitario3]
+ vr_total3: $_POST[vr_total3]

+ descripcion4: $_POST[descripcion4]
+ dias4: $_POST[dias4]
+ cantidad4: $_POST[cantidad4]
+ vr_unitario4: $_POST[vr_unitario4]
+ vr_total4: $_POST[vr_total4]

+ descripcion5: $_POST[descripcion5]
+ dias5: $_POST[dias5]
+ cantidad5: $_POST[cantidad5]
+ vr_unitario5: $_POST[vr_unitario5]
+ vr_total5: $_POST[vr_total5]

+ descripcion6: $_POST[descripcion6]
+ dias6: $_POST[dias6]
+ cantidad6: $_POST[cantidad6]
+ vr_unitario6: $_POST[vr_unitario6]
+ vr_total6: $_POST[vr_total6]


+ subtotal: $_POST[subtotal]
+ iva: $_POST[iva]
+ retefuente: $_POST[retefuente]
+ total: $_POST[total]
+ observaciones: $_POST[observaciones]
+ empresa: $_POST[empresa]
+ encargado: $_POST[encargado]
+ cargo: $_POST[cargo]
+ email: $_POST[email]
+ telefono: $_POST[telefono]
+ direccion: $_POST[direccion]
+ fecha: $_POST[fecha]";


fputs ($archivo, $datos);
}
echo $pulsado;
fclose ($archivo);
?>
<?php
include "libmail.php";
$m= new Mail;
//correo desde el que se enviará
$m->From( "[email protected]" );
//correo al que se enviará. Se puede poner en ambos lugares el mismo correo
$m->To( "[email protected]" );
//el subject del email, será el email que haya escrito el usuario, salvo que lo cambiemos, pon lo que quieras
$m->Subject( "Orden de Alquiler" );
//variables que hayamos declarado en la pelicula de flash
$m->Body( "ciudad: $_POST[ciudad]
dia: $_POST[dia]
mes: $_POST[mes]
año: $_POST[anio]
cotizacion No: $_POST[cotizacion]

descripcion1: $_POST[descripcion1]
dias1: $_POST[dias1]
cantidad1: $_POST[cantidad1]
vr_unitario1: $_POST[vr_unitario1]
vr_total1: $_POST[vr_total1]

descripcion2: $_POST[descripcion2]
dias2: $_POST[dias2]
cantidad2: $_POST[cantidad2]
vr_unitario2: $_POST[cantidad2]
vr_total2: $_POST[vr_total2]

descripcion3: $_POST[descripcion3]
dias3: $_POST[dias3]
cantidad3: $_POST[cantidad3]
vr_unitario3: $_POST[vr_unitario3]
vr_total3: $_POST[vr_total3]

descripcion4: $_POST[descripcion4]
dias4: $_POST[dias4]
cantidad4: $_POST[cantidad4]
vr_unitario4: $_POST[vr_unitario4]
vr_total4: $_POST[vr_total4]

descripcion5: $_POST[descripcion5]
dias5: $_POST[dias5]
cantidad5: $_POST[cantidad5]
vr_unitario5: $_POST[vr_unitario5]
vr_total5: $_POST[vr_total5]

descripcion6: $_POST[descripcion6]
dias6: $_POST[dias6]
cantidad6: $_POST[cantidad6]
vr_unitario6: $_POST[vr_unitario6]
vr_total6: $_POST[vr_total6]

subtotal: $_POST[subtotal]
iva: $_POST[iva]
retefuente: $_POST[retefuente]
total: $_POST[total]
observaciones: $_POST[observaciones]
empresa: $_POST[empresa]
encargado: $_POST[encargado]
cargo: $_POST[cargo]
email: $_POST[email]
telefono: $_POST[telefono]
direccion: $_POST[direccion]
fecha: $_POST[fecha]" );
//Si queremos que el correo se envíe a más cuentas de correo, quitar las barras de comentario y especificar los correos
//$m->Cc( "alguien@algun_server.au");
//$m->Bcc( "alguien_mas@otro_server.es");
$m->Priority(1) ;
$m->Attach( "formulario.csv", "application/vnd.ms-excel", "attachment" );
$m->Send();
?>