Ver Mensaje Individual
  #8 (permalink)  
Antiguo 22/04/2013, 02:16
kobety
 
Fecha de Ingreso: marzo-2013
Ubicación: Jaén, Andalucía
Mensajes: 129
Antigüedad: 11 años, 1 mes
Puntos: 2
Respuesta: Exportar datos a word y excel desde php

no me funciona con ninguno de ellos..... os dejo mi código a ver si sabéis que puedo hacer...muchas gracias de antemano!

Código PHP:
Ver original
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title></title>
  5. </head>
  6.  
  7. <body>
  8.  
  9. <?php
  10. require_once('funciones.php');
  11. include('config.php');
  12. conectar('localhost',);
  13. ini_set("default_charset", "utf-8");
  14. mysql_query("SET NAMES 'utf8'");
  15. ini_set('error_reporting',0);
  16.  
  17. $link = mysql_connect("localhost")
  18.     or die ("Error al conectar a la base de datos.");
  19. mysql_select_db("campus2013", $link)
  20.     or die ("Error al conectar a la base de datos.");
  21.  
  22.  
  23. // Lee la plantilla
  24. $plantilla = file_get_contents('plantilla_titulo.rtf');
  25.  
  26.  
  27. // Agregamos los escapes necesarios
  28. $plantilla = addslashes($plantilla);
  29. $plantilla = str_replace('\r','\\r',$plantilla);
  30. $plantilla = str_replace('\t','\\t',$plantilla);
  31.  
  32. // Datos de la plantilla
  33. $nombre = $_POST["trabajador"];
  34. $curso = $_POST["curso"];
  35. $fechahoy = date("d-m-Y", time());
  36.  
  37. $plantilla2 = str_replace("\'d3",'Ó',$plantilla);
  38. $plantilla3 = str_replace("\'f1",'ñ',$plantilla2);
  39. $plantilla4 = str_replace("\'f3",'ó',$plantilla3);
  40. $plantilla5 = str_replace("\'ed",'í',$plantilla4);
  41. $plantilla5=utf8_encode($plantilla5);
  42. var_dump($plantilla5);
  43.  
  44. // Procesa la plantilla
  45. eval( '$rtf = <<<EOF_RTF
  46. ' . $plantilla5 . '
  47. EOF_RTF;
  48. ' );
  49.  
  50. // Guarda el RTF generado, el nombre del RTF en este caso sera el apellido-nombre.fechaactual.rtf
  51. file_put_contents("$nombre-$fechahoy.rtf",$rtf=utf8_decode($rtf));
  52.  
  53. echo "<body bgcolor='#FFFFE0'> <img src='imagenes/campus.png' width=178 height=80><br><br><br>";
  54.  
  55. echo "<a href=\"$nombre-$fechahoy.rtf\">descargar</a>";
  56.  
  57. //@unlink($f); //Borro el temporal creado
  58. ?>
  59.  
  60. </body>
  61. </html>