Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

454
Vistas
Read Empty Cells node.js xlsx

I am using the node.js package xlsx to access an xlsx file using the following code:

const XLSX = require("xlsx")

wbInput.addEventListener("change", (evt) => {
    if (wbInput.files.length === 0)
      return;
  
    actOnXLSX(wbInput.files[0]);
  }, false);
  
  
  async function actOnXLSX (file) {
    const fileReader = new FileReader();
  
    const data = await new Promise((resolve, reject) => {
        fileReader.onload = () => {
          resolve(fileReader.result);
        };
        fileReader.onerror = reject;
  
        fileReader.readAsArrayBuffer(file);
      })
      .finally(() => {
        fileReader.onerror = fileReader.onload = null;
      });
  
    const workbook = XLSX.read(data);
    const worksheet = workbook.Sheets[workbook.SheetNames[0]];
    console.log(worksheet)
    
    var columnA = []

    for (let z in worksheet) {
        if(z.toString()[0] === 'A'){
          columnA.push(worksheet[z].v);
        }
      }
      
    console.log(columnA);

    for (let i= 1; i < columnA.length; i++) {
        console.log(columnA[i], i)
    }
}

This works fine for when all the cells between the first and the end cell contain data, but when there is an empty cell the array skips it instead of storing it as an empty entry. Is it possible for it to store when there are empty codes? I will be using i to simultaneously write to a spreadsheet using another function so the array always needs to remain true to the spreadsheet it is reading.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda