Foros del Web » Programando para Internet » Jquery »

pasar tabla html a excel

Estas en el tema de pasar tabla html a excel en el foro de Jquery en Foros del Web. buenas tardes estoy teniendo un problema al exportar una tabla a excel, el tema esta en que no me toma los value de los input ...
  #1 (permalink)  
Antiguo 26/05/2015, 14:31
Avatar de maximendez88  
Fecha de Ingreso: septiembre-2012
Ubicación: Montevideo
Mensajes: 131
Antigüedad: 11 años, 7 meses
Puntos: 3
pasar tabla html a excel

buenas tardes estoy teniendo un problema al exportar una tabla a excel, el tema esta en que no me toma los value de los input cuando lo paso al excel... espero que alguien me de una mano....



Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  4. <title>Informe Notas</title>
  5. <script language="javascript" type="text/javascript" src="informenotas.js"></script>
  6. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  7. </head>
  8. <center>
  9.  
  10. <div id="creacion">
  11. <form enctype="multipart/form-data"  name="formplantilla"  method="post">
  12. <table id="tblcrear" border="1" width="800" align="center">
  13. <tr>
  14. <td>Institución</td>
  15. <td><input type="text" id="institucion" name="inst" /></td>
  16. <td></td>
  17. </tr>
  18. <tr>
  19. <td>Nivel de curso</td>
  20. <td><input type="text" id="nivelcurso" name="nivcurso"/></td>
  21. <td></td>
  22. </tr>
  23. <tr>
  24. <td>Cantidad de alumnos</td>
  25. <td><input type="text" id="cantalumnos" name="cntalumnos" /></td>
  26. </tr>
  27. <tr>
  28. <td></td>
  29. <td><input type="button" id="crearplantilla"  onclick="crearinforme();" value="Crear Plantilla" /></td>
  30. </tr>
  31. </form>
  32. </div>
  33.  
  34. <div id="informe" style="display:none;">
  35. <form enctype="multipart/form-data" action="crearexcel.php" target="new" id="formcrearexcel" name="formcrearexcel" method="post">
  36. <table id="tblcabecerainfo" border="1" style="display:none;" border="0" width="830" align="center">
  37. <table id="tbldatosinfo" style="display:none;" border="0" width="830" align="center">
  38. <input type="button" value="Crear Excel" id="btncrearexcel" />
  39. </form>
  40. </div>
  41.  
  42. <script type="text/javascript">
  43. $(function() {
  44.     $("#btncrearexcel").click(function(e) {
  45.     window.open('data:application/vnd.ms-excel,' + encodeURIComponent($('#informe').html()));
  46.     e.preventDefault();
  47. });
  48. });
  49. </center>
  50.  
  51. </body>
  52. </html>




Código Javascript:
Ver original
  1. // JavaScript Document
  2. function crearinforme()
  3. {
  4.    
  5.     //valido institucion
  6.     if (document.formplantilla.institucion.value.length==0){
  7.        alert("Tiene que escribir el nombre de la institución")
  8.        document.fvalida.institucion.focus()
  9.        return 0;
  10.     }
  11.    
  12.     //valido el nivel del curso
  13.     if (document.formplantilla.nivelcurso.value.length==0){
  14.        alert("Tiene que escribir el nivel del curso")
  15.        document.fvalida.nivelcurso.focus()
  16.        return 0;
  17.     }
  18.    
  19.     //valido la cantidad de alumnos
  20.     if (document.formplantilla.cantalumnos.value.length==0){
  21.        alert("Tiene que escribir la cantidad de alumnos")
  22.        document.fvalida.cantalumnos.focus()
  23.        return 0;
  24.     }
  25.    
  26.    
  27.    
  28.     document.getElementById('creacion').style.display="none";
  29.     document.getElementById('informe').style.display="block";
  30.            
  31.    
  32.     var tablecabecera = document.getElementById('tblcabecerainfo');
  33.     tablecabecera.style.display="block"
  34.    
  35.     var rowinstitucion = tablecabecera.insertRow(0);
  36.     var cell= rowinstitucion.insertCell(0);
  37.     var institucion=document.getElementById('institucion').value
  38.    
  39.      
  40.     cell.innerHTML = "Institución: "+ "<b>"+institucion+"</b>"
  41.     cell.style.width="200px"
  42.    
  43.    
  44.    
  45.     var nivelcurso=document.getElementById('nivelcurso').value
  46.     cell1= rowinstitucion.insertCell(1);
  47.     cell1.innerHTML="Nivel de curso: "+"<b>"+ nivelcurso+"</b>"
  48.     cell1.style.width="250px"
  49.    
  50.    
  51.     cell2= rowinstitucion.insertCell(2);
  52.    
  53.     cell3= rowinstitucion.insertCell(3);
  54.    
  55.     cell4= rowinstitucion.insertCell(4);
  56.  
  57.    
  58.    
  59.    
  60.    
  61.    
  62.     var rowdatos=tablecabecera.insertRow(1);
  63.    
  64.    
  65.     celldatos2=rowdatos.insertCell(0);
  66.     celldatos2.innerHTML="Nombre"
  67.     celldatos2.style.width="214px"
  68.    
  69.     celldatos3=rowdatos.insertCell(1);
  70.     celldatos3.innerHTML="Apellido"
  71.     celldatos3.style.width="200px"
  72.        
  73.     celldatos4=rowdatos.insertCell(2);
  74.     celldatos4.innerHTML="Nota del parcial"
  75.     celldatos4.style.width="200px"
  76.    
  77.     celldatos5=rowdatos.insertCell(3);
  78.     celldatos5.innerHTML="Apreciación docente"
  79.     celldatos5.style.width="200px"
  80.    
  81.     celldatos6=rowdatos.insertCell(4);
  82.     celldatos6.innerHTML="Otras consideraciones"
  83.     celldatos6.style.width="200px"
  84.    
  85.    
  86.     var insertdatosinfo=document.getElementById('tbldatosinfo');
  87.     insertdatosinfo.border="1"
  88.    
  89.     insertdatosinfo.style.display="block";
  90.    
  91.     var cantalumnos=document.getElementById('cantalumnos').value;
  92.    
  93.     cantcolumnas=0;
  94.    
  95.    
  96.                
  97.    
  98.     for(i=0;i<cantalumnos;i++)
  99.     {
  100.    
  101.     cantcolumnas=0;
  102.    
  103.     var rowinsertdatos=insertdatosinfo.insertRow(i);
  104.    
  105.     while(cantcolumnas<5)
  106.     {
  107.         cellalgo= rowinsertdatos.insertCell(cantcolumnas)
  108.         cellalgo.innerHTML="<input type='text' name='datoalumno'>"
  109.         cellalgo.style.width="200px"
  110.         cantcolumnas++;    
  111.     }
  112.     }
  113.  
  114. }

Etiquetas: ajax, excel, html, input, javascript, js, php, tabla
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 09:42.