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

exceltables4js

v3.1.0

Published

Convierte un objeto de tabla Excel a JSON.

Readme

ExcelTables4Js

ExcelTables4Js es una librería que convierte tablas dentro de archivos Excel (.xlsx) en objetos JSON, permitiendo al usuario elegir entre dos formatos de salida: un arreglo de arreglos o un objeto donde las llaves son los nombres de las columnas.

Esto utiliza la librera ExcelJS para leer el archivo Excel y extraer los datos de la tabla especificada. Y simplifica el proceso de extraer objetos tipo tablas de archivos Excel.

Parámetros de entrada

_file

  • Tipo: File
  • Descripción: Archivo Excel que se desea procesar
  • Requerido: Sí

_tableName

  • Tipo: string
  • Descripción: Nombre de la tabla dentro del archivo Excel que se desea procesar
  • Requerido: Sí

_isColumnsObjects

  • Tipo: boolean
  • Descripción: Define la estructura de salida de los datos procesados
  • Valores posibles:
    • true: Los datos se transforman en un objeto donde las columnas actúan como claves
    • false: Los datos se transforman en un arreglo de arreglos
  • Requerido: Sí

customDataFunction

  • Tipo: Function
  • Descripción: Función personalizada para transformar los datos durante el procesamiento
  • Requerido: No
  • Por defecto: undefined

🚀 Características

  • Convierte una tabla específica en un archivo Excel a JSON.
  • Soporta dos formatos de salida:
    1. Array de arreglos: Las filas son representadas como arreglos.
    2. Objetos con llaves: Los nombres de las columnas son las llaves y los datos de las filas son los valores.
  • Fácil de usar con JavaScript o TypeScript.

📦 Instalación

Usa npm para instalar la librería:

npm install ExcelTables4Js

📖 Uso

import ExcelTables4Js from 'ExcelTables4Js';


//file example e.target.files[0]
const processExcel = async (file) => {
  
  const tableName = 'MyTable'; // Nombre de la tabla dentro del archivo Excel
  const isColumnsObjects = true; // Cambiar a `false` para obtener un array de arreglos

  const result = await ExcelTables4Js(file, tableName, isColumnsObjects);

  console.log(result);
};

Ejemplo con función personalizada

const customFunction = (value: any, column: string) => {
  if (column === 'Price') {
    return parseFloat(value) || 0;
  }
  return value;
};

ExcelTables4Js(file, tableName, true, customFunction).then((result) => {
  console.log(result);
});

Objeto con columnas como claves (_isColumnsObjects = true)

{
  "columns": ["Column1", "Column2", "__fileSourceName"],
  "data": {
    "Column1": ["Value1", "Value2"],
    "Column2": ["ValueA", "ValueB"],
    "__fileSourceName": ["example.xlsx", "example.xlsx"]
  }
}

Arreglo de arreglos (_isColumnsObjects = false)

{
  "columns": ["Column1", "Column2", "__fileSourceName"],
  "data": [
    ["Value1", "ValueA", "example.xlsx"],
    ["Value2", "ValueB", "example.xlsx"]
  ]
}

🌟 Contribuciones

¡Las contribuciones son bienvenidas! Si tienes ideas para mejorar esta librería o encuentras algún problema, por favor sigue estos pasos:

  1. Haz un fork del proyecto desde el repositorio oficial:
    MilzCode/ExcelTables4Js.

  2. Crea una nueva rama para tu funcionalidad o corrección de errores:

    git checkout -b nombre-de-tu-rama

`` 3. Haz un pull request con tus cambios para que sean revisados.

📂 Repositorio Encuentra el código fuente de este proyecto en GitHub: https://github.com/MilzCode/ExcelTables4Js