Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

452
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda