Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

148
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!