Exportar Tablas HTML a Excel (con ExcelJS + Observer)

Agrega un botón a cada tabla HTML para exportarla a Excel usando ExcelJS

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

作者
Jairo Abraham Bernal Villanueva
日安装量
0
总安装量
1
评分
0 0 0
版本
1.2
创建于
2025-05-09
更新于
2025-05-09
大小
4.6 KB
许可证
MIT
适用于
所有网站

Exportar Tablas HTML a Excel (Greasemonkey/Tampermonkey Script)

Este script de usuario detecta automáticamente todas las tablas HTML visibles en cualquier página web y agrega un botón flotante a cada una para exportarla como archivo .xlsx, utilizando ExcelJS.

✨ Características

  • Botón de exportación individual para cada tabla
  • Soporte completo para celdas fusionadas (rowspan, colspan)
  • Exportación directa como archivo .xlsx
  • No requiere configuración ni interacción con el código del sitio
  • Compatible con sitios que renderizan contenido dinámicamente (React, Angular, etc.)
  • Registro limpio en consola para depuración (console.clear() y console.log())

🧠 Cómo funciona

  • Usa MutationObserver para detectar tablas aunque se agreguen dinámicamente al DOM
  • Añade un botón discreto en la esquina superior derecha de cada tabla visible
  • Genera un archivo .xlsx usando la biblioteca ExcelJS

📦 Tecnologías

📥 Instalación

  1. Instala Tampermonkey en tu navegador.
  2. Haz clic en este enlace para instalar el script:
    👉 Exportar Tablas HTML a Excel
  3. Navega cualquier sitio con tablas. Verás un botón 📥 sobre cada tabla.

🛡 Seguridad

Este script:

  • No recopila ni transmite datos
  • No accede a servidores externos (salvo para cargar ExcelJS desde CDN)
  • No modifica el contenido original de la página, solo lo lee y complementa

🧪 Ejemplos de uso

  • Paneles de control empresariales
  • Sistemas ERP o CRM sin función de exportación
  • Portales académicos, gubernamentales o internos