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

138
Visualizações
for loop is taking too much time and causes page crach

I am manipulating Excel files using javascript, I am converting the file into a json object then looping for each row . I am using this code

document.getElementById('confirm').addEventListener("click", () => {
    XLSX.utils.json_to_sheet(data, 'out.xlsx');
    if (selectedfile && etat == 0) {   
        let fileReader = new FileReader();
        fileReader.readAsBinaryString(selectedfile);
        fileReader.onload = (event) => {
            etat++;
            let data = event.target.result;
            let workbook = XLSX.read(data, { type: "binary" });
            console.log(workbook);
            workbook.SheetNames.forEach(sheet => {
                let rowObject = XLSX.utils.sheet_to_row_object_array(workbook.Sheets[sheet],{raw: false});
                let ok = JSON.stringify(rowObject, undefined, 4);
                let tab = JSON.parse(ok);
                let num = tab.length;
                console.log(parseInt(num/1000));
                for(j = 0;j<parseInt(num/1000)+1;j++){
                    let row = j *1000;
                    let ligne;
                    if(j == num)
                    ligne = num;
                    else
                    ligne = (j+1)* 1000;
                   let table = [];
for(i = row; i<ligne; i++){
    let jour = tab[i].JOUR;
    let date = tab[i].DATE;
    let compte = tab[i].COMPTE;
    let code = tab[i].CODE;
    let libelles = tab[i].LIBELLES;
    let debit = tab[i].DEBIT ;
    let creadit = tab[i].CREDIT;
    let ech = tab[i].ECH;
    let LETT = tab[i].LETT;
    table.push( [jour , date,compte , code , libelles , debit , creadit , ech , LETT] );
    console.log(i);
}
                }
                /**/
            });
        }
    }
}
);

The excel file contains more than 17k rows, this code takes too much time ( over 15 mins ) and causes crashes.

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