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

234
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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