html-table-excel-exporter
Version:
Biblioteca JavaScript para exportar tabelas HTML para arquivos Excel (.xlsx)
2 lines (1 loc) • 968 B
JavaScript
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).htmlTableExcelExporter={})}(this,(function(e){"use strict";e.htmlExportTableToExcel=function(){let e=null,n=null,o="Baixando...",t=null,i="relatorio",l=document.createElement("a");function d(){t?(e&&(e.innerHTML=o,e.disabled=!0),l.href=t?"data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,"+encodeURIComponent(t.outerHTML):(console.error("Tabela não definida!"),""),l.download=`${i}.xlsx`,document.body.appendChild(l),l.click(),document.body.removeChild(l),e&&(e.innerHTML=n,e.disabled=!1)):console.error("Nenhuma tabela foi definida!")}return{setBtnAction:function(o){e=o,n=e.innerHTML,e.addEventListener("click",d)},setLoadingContent:function(e="Baixando..."){o=e},setTable:function(e){t=e},setFileName:function(e="relatorio"){i=e},download:d}}}));