Quiero obtener una forma de descargar (EXPORTAR) la tabla HTML en otro archivo HTML.
por ejemplo, ahora estoy en index.html pero tengo otro archivo con el nombre de table.html que contiene la tabla que quiero imprimir.
básicamente..
Cuando LOAD index.html empiezo a descargar TABLE en table.html
Intenté esto, pero no funcionó ...
ÍNDICE.HTML
<!DOCTYPE html> <html> <script src="http://www.w3schools.com/lib/w3data.js"></script> <script src="./dist/exportToExcel.js"></script> <body> <div w3-include-html="./table.html"></div> <script> w3IncludeHTML(); function printEXCEL(type, fn, dl) { var elt = document.getElementById("tbl_exporttable_to_xls"); var wb = XLSX.utils.table_to_book(elt, { sheet: "sheet1" }); return dl ? XLSX.write(wb, { bookType: type, bookSST: true, type: "base64" }) : XLSX.writeFile(wb, fn || "MySheetName." + (type || "xlsx")); } printEXCEL("xlsx"); </script> </body> </html>TABLA.HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Document</title> <script src="./dist/exportToExcel.js"></script> </head> <body> <table id="tbl_exporttable_to_xls" border="1"> <thead> <th>Sr</th> <th>Name</th> <th>Location</th> <th>Job Profile</th> </thead> <tbody> <tr> <td>1</td> <td><p>کوردی</p></td> <td>فۆنت</td> <td>سڵاو</td> </tr> <tr> <td>2</td> <td><p>Sagar Gada</p></td> <td>California</td> <td>Sr FullStack Dev</td> </tr> </tbody> </table> </body> </html>