Antes que nada chicos, gracias por vuestra ayuda, da gusto preguntar aquí.
Al final creo el excel utilizando el archivo
agpform.php que lo he visto googleando y disponible para descarga. En resumen, formulario en el html, proceso con el archivo cagpform y se crea el excel en el directorio, pero aún me queda una duda.
Sólo comentar una duda que tengo para que en excel aparezcán las comillas, acentos,etc. y n
o sé dónde colocar el utf8_decode en el archivo agpform.php cuyo código publico debajo para la codificación de carácteres.
Código PHP:
Ver original<?php
$success = "confirmacion.php";
$error = "error.php";
// Change this to the character(s) you want to be placed instead of line breaks(new line, enter, etc)
$lbChar = " "; // default is a space, you may change it to whatever you want
// Don't change anything below this line
// Determine if the form was sent through the GET methog or the POST method.
if($_POST){
$array = $_POST;
} else if($_GET){
$array = $_GET;
} else {
die("You must Access this file through a form."); // If someone accesses the file directly, it wont work :) }
//Check if the filename was sent through the form or not
if(!$array['filename']){
// if the filename wasnt sent through the form, it will become form.xls, you can change the default if you want.
$array['filename'] = "datos-registro.xls"; //Set the file to save the information in
} else {
if(!(stristr($array['filename'],".xls"))){ $array['filename'] = $array['filename'] . ".xls";
}
}
// Define the tab and carriage return characters:
$tab = "\t"; //chr(9);
$cr = "\n"; //chr(13);
if($array){
// Make The Top row for the excel file and store it in the $header variable
foreach($keys as $key){
$header .= $key . $tab;
}
}
$header .= $cr;
//Make the line with the contents to write to the excel file.
foreach($keys as $key){
$array[$key] = preg_replace('/([\r\n])/e',"ord('$1')==10?'':''",$array[$key]); $data .= $array[$key] . $tab ;
}
}
$data .= $cr;
$final_data = $data; // If the file does exist, then only write the information the user sent
} else {
$final_data = $header . $data; // If file does not exist, write the header(first line in excel with titles) to the file
}
// open the file and write to it
$fp = fopen($array['filename'],"a"); // $fp is now the file pointer to file $array['filename']
if($fp){
fwrite($fp,$final_data); //Write information to the file fclose($fp); // Close the file // Success
} else {
// Error
}
}
?>
Cita: Yo suelo usar "php_writeexcel-0.3.0", viene con algunos ejemplos para colorear las celdas, el texto, etc.
P.D.: Un poquito tonto el cliente ¿no?.
Investigaré el que dices, porque seguramente me pedirán que se permita colorear celdas, etc.
Respecto al cliente, no es por hacer sangre, pero cada proyecto algunos clientes me lo ponen más complicado por la falta de cooperación que tienen y para escuchar recomendaciones.