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

232
Views
Why an external row is inserting while writing the excel file in Nodejs?

I am learning Nodejs and I am reading and writing the excel file using Nodejs by the module "XLSX" npm. Reading and writing the data done successfully. But there is an external row which is inserting in place of first row and the data of row is [A, B, C, D..... the column name].

How to solve that problem? the code is below.

 {
 var filepath = './src/assets/uploads/csv template/fileName.csv';
var workbook = XLSX.readFile(filepath);
var sheet_name_list = workbook.SheetNames;
var xlData = XLSX.utils.sheet_to_json(workbook.Sheets[sheet_name_list[0]], { header: 'A' });
let worksheet = workbook.Sheets[sheet_name_list[0]];
if(xlData){
    xlData[0]["L"] = "hash";
    for(let i = 1; i< xlData.length; i++){
        xlData[i]["L"] = generatehasnumber(xlData[i]["A"], xlData[i]["D"]);
    }

}

if(xlData[1]["A"] == "A" )
{
    xlData.shift();
}
const ws = XLSX.utils.json_to_sheet(xlData)
const wb = XLSX.utils.book_new()
XLSX.utils.book_append_sheet(wb, ws, "hash")
XLSX.writeFile(wb, './src/assets/uploads/csv template/fileName.csv')  
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

try adding the flag for not including header row in output:

const ws = XLSX.utils.json_to_sheet(xlData, { skipHeader: true })
about 4 years ago · Juan Pablo Isaza Report
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!