npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

html-table-excel-exporter

v1.0.0

Published

Biblioteca JavaScript para exportar tabelas HTML para arquivos Excel (.xlsx)

Readme

html-table-excel-exporter

Uma biblioteca JavaScript simples para exportar tabelas HTML para arquivos Excel (.xlsx) sem dependências externas.

npm version License: MIT

Instalação

NPM

npm install html-table-excel-exporter

CDN

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/table-excel-exporter.min.js"></script>

Uso

// Importar a biblioteca (se estiver usando módulos)
import { exportTableToExcel } from 'table-excel-exporter';

// Ou usar diretamente se incluída via CDN
const exporter = exportTableToExcel();

// Configurar a tabela a ser exportada
const minhaTabela = document.getElementById('minhaTabela');
exporter.setTable(minhaTabela);

// Configurar o nome do arquivo (opcional)
exporter.setFileName('meus-dados');

// Método 1: Exportar diretamente
document.getElementById('btnExportar').addEventListener('click', () => {
  exporter.download();
});

// Método 2: Configurar um botão para iniciar o download
const btnExportar = document.getElementById('btnExportar');
exporter.setBtnAction(btnExportar);

// Alterar o texto exibido durante o download (opcional)
exporter.setLoadingContent('Gerando Excel...');

Exemplo Completo

<!DOCTYPE html>
<html>
<head>
  <title>Exportar Tabela para Excel</title>
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/html-table-excel-exporter.min.js"></script>
</head>
<body>
  <table id="minhaTabela">
    <thead>
      <tr>
        <th>Nome</th>
        <th>Email</th>
        <th>Telefone</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>João Silva</td>
        <td>[email protected]</td>
        <td>(11) 98765-4321</td>
      </tr>
      <tr>
        <td>Maria Souza</td>
        <td>[email protected]</td>
        <td>(21) 91234-5678</td>
      </tr>
    </tbody>
  </table>
  
  <button id="btnExportar">Exportar para Excel</button>
  
  <script>
    document.addEventListener('DOMContentLoaded', function() {
      const exporter = exportTableToExcel();
      exporter.setTable(document.getElementById('minhaTabela'));
      exporter.setFileName('contatos');
      exporter.setBtnAction(document.getElementById('btnExportar'));
    });
  </script>
</body>
</html>

API

htmlExportTableToExcel()

Inicializa o exportador e retorna um objeto com os seguintes métodos:

setTable(tabela)

Define a tabela HTML que será exportada para Excel.

  • tabela: Elemento HTML da tabela a ser exportada (obrigatório)

setFileName(nome)

Define o nome do arquivo Excel a ser gerado.

  • nome: String com o nome do arquivo sem extensão (padrão: 'relatorio')

setBtnAction(botao)

Configura um botão para iniciar o download quando clicado.

  • botao: Elemento HTML do botão

setLoadingContent(texto)

Define o texto exibido no botão durante o download.

  • texto: String com o texto (padrão: 'Baixando...')

download()

Inicia o download da tabela como arquivo Excel.

Limitações

  • A biblioteca exporta o HTML da tabela para um formato que o Excel pode abrir, mas não cria um arquivo XLSX nativo.
  • Estilos CSS da tabela não são preservados no arquivo Excel.
  • Para tabelas muito grandes, considere usar uma biblioteca mais robusta como SheetJS.

Contribuições

Contribuições são bem-vindas! Por favor, abra uma issue ou pull request no GitHub.

Licença

MIT