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 🙏

© 2025 – Pkg Stats / Ryan Hefner

rs-excel-lite

v2.0.0

Published

Complete standalone Excel export library for browser with JSZip included

Downloads

325

Readme

RsExcelLite v2.0.0

npm version License: MIT Standalone

Complete standalone Excel export library for browser with JSZip included.

✨ Características

  • ✅ Completamente standalone – JSZip incluido (~60KB minificado)
  • ✅ Soporte para múltiples hojas – Organiza tus datos en varias hojas
  • ✅ Cero configuración – Solo incluye y usa
  • ✅ Ajuste automático de columnas – Ancho inteligente según contenido
  • ✅ Auto-filtros – Activación con una sola opción
  • ✅ Protección de hojas – Con soporte para contraseña (hasheada compatible con Excel)
  • ✅ Congelar paneles – Soporte para freezePane
  • ✅ Estilos de cabecera automáticos – Negrita en primera fila si se define
  • ✅ Soporte completo de tipos – Texto, números, fechas (Date), booleanos
  • ✅ Conversión automática de objetos – Con objectsToArrays()
  • ✅ Solo navegador – No requiere Node.js
  • ✅ Excelente compatibilidad – Funciona en todos los navegadores modernos

📦 Instalación

NPM

npm install rs-excel-lite

CDN (Recomendado)

<!-- Versión standalone completa (JSZip incluido) -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/rs-excel-lite.standalone.min.js"></script>

Descarga directa

rs-excel-lite.standalone.min.js

🚀 Uso en 30 segundos

<!DOCTYPE html>
<html>
<head>
    <title>Exportar Excel</title>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/rs-excel-lite.standalone.min.js"></script>
</head>
<body>
<button onclick="exportarExcel()">Exportar a Excel</button>

<script>
    function exportarExcel() {
        const datos = [
            ['Nombre', 'Edad', 'Email', 'Fecha de registro'],
            ['Juan Pérez', 30, '[email protected]', new Date('2024-01-15')],
            ['María López', 25, '[email protected]', new Date()],
            ['Carlos Ruiz', 35, '[email protected]', new Date('2024-02-20')]
        ];

        RsExcelLite.exportToExcel(datos, 'empleados.xlsx', 'Hoja1', {
            autoFit: true,
            headerRow: true,
            headerStyle: true,
            enableFilters: true,
            freezePane: 'A2'
        });
    }
</script>
</body>
</html>

📖 API Completa

Método principal

// Exportar hoja única
RsExcelLite.exportToExcel(aoa, filename?, sheetName?, options?)

// Exportar múltiples hojas
RsExcelLite.exportSheets(sheets, filename?)

// Compatibilidad retrocedida
RsExcelLite.export(aoa, filename?, sheetName?)

Parámetros comunes

  • aoa: Array<Array> – Datos en formato array de arrays
  • filename: string – Nombre del archivo (por defecto: 'export.xlsx')
  • sheetName: string – Nombre de la hoja (por defecto: 'Sheet1')
  • sheets: Array<{ name: string; data: Array<Array>; options?: Object }> – Configuración de múltiples hojas

Opciones de exportación

La siguiente tabla describe las opciones disponibles para configurar el comportamiento del componente:

| Opción | Tipo | Por defecto | Descripción | |--------|------|-------------|-------------| | autoFit | boolean | false | Ajusta el ancho de columnas automáticamente | | headerRow | boolean | false | Trata la primera fila como encabezado | | headerStyle | boolean | true | Aplica estilo de negrita al encabezado | | enableFilters | boolean | false | Habilita autofiltros | | protectSheet | boolean | false | Protege la hoja de cálculo | | protectPassword | string | '' | Contraseña para la protección (hasheada en Excel) | | freezePane | string | null | Celda de referencia para congelar paneles (ej. 'A2') |

Métodos auxiliares

// Convertir índice de columna (0-based) a letra Excel
RsExcelLite.getColumnLetter(0);  // 'A'
RsExcelLite.getColumnLetter(26); // 'AA'

// Calcular ancho óptimo de columnas
const widths = RsExcelLite.getColumnWidths(datos);

// Escapar texto para XML
const escaped = RsExcelLite.escapeXml('<span>texto</span>');

// Convertir objetos a arrays
const aoa = RsExcelLite.objectsToArrays(data, headers, { includeHeaders: true });

// Validar nombre de hoja
const validation = RsExcelLite.isValidSheetName('Nombre Hoja');

// Helper para crear configuración de hojas
const sheet = RsExcelLite.createSheetConfig('Hoja1', datos, { autoFit: true });

📊 Ejemplos prácticos

Ejemplo 1: Múltiples hojas

const sheets = [
    RsExcelLite.createSheetConfig('Clientes', [
        ['ID', 'Nombre', 'Email'],
        [1, 'Ana', '[email protected]']
    ], { autoFit: true, headerRow: true }),
    RsExcelLite.createSheetConfig('Ventas', [
        ['Producto', 'Total'],
        ['Laptop', 1200]
    ], { enableFilters: true })
];

RsExcelLite.exportSheets(sheets, 'reporte.xlsx');

Ejemplo 2: Protección con contraseña

RsExcelLite.exportToExcel(datos, 'confidencial.xlsx', 'Datos', {
    protectSheet: true,
    protectPassword: 'miClaveSegura',
    autoFit: true
});

Ejemplo 3: Conversión desde objetos

const data = [
    { id: 1, name: 'Juan', active: true },
    { id: 2, name: 'María', active: false }
];

const aoa = RsExcelLite.objectsToArrays(data, [['ID', 'id'], ['Nombre', 'name'], ['Activo', 'active']]);
RsExcelLite.exportToExcel(aoa, 'usuarios.xlsx', 'Usuarios', { headerRow: true });

🔧 Builds disponibles

Archivos de la Biblioteca

La siguiente tabla describe los diferentes archivos disponibles y sus características:

| Archivo | Tamaño | Descripción | Uso recomendado | |---------|--------|-------------|-----------------| | rs-excel-lite.standalone.min.js | ~60KB | Todo incluido (JSZip + RsExcelLite) | Navegador (CDN) | | rs-excel-lite.min.js | ~15KB | Solo RsExcelLite | Si ya tienes JSZip | | index.esm.js | ~15KB | Módulo ES | Webpack, Vite, Rollup | | index.cjs.js | ~15KB | CommonJS | Node.js (con jsdom) |

🌐 Compatibilidad

  • Chrome 60+
  • Firefox 55+
  • Safari 10.1+
  • Edge 79+
  • iOS Safari 10.3+
  • Android Chrome 60+

📄 Licencias

RsExcelLite - MIT License

Copyright (c) 2025 Rogelio Urieta Camacho (RojeruSan)

MIT License - Ver archivo LICENSE

JSZip - MIT/GPLv3 License

Copyright (c) 2009-2016 Stuart Knightley, David Duponchel, Franz Buchinger, António Afonso

Dual licensed under MIT or GPLv3 - Ver archivo LICENSE-JSZIP.md

🤝 Contribuir

  • Haz fork del repositorio
  • Crea una rama: git checkout -b feature/nueva-funcion
  • Haz commit: git commit -am 'Añade nueva función'
  • Push: git push origin feature/nueva-funcion
  • Abre un Pull Request

Hecho con ❤️ por RojeruSan

❤️ Donaciones

Donar