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

436
Vistas
Error: Corrupted zip : can't find end of central directory "When trying to read a slice of .xlsx file."- XLSX

I am trying to read the .xlsx file using FileReader and XLSX module. So If I am trying to read the whole .xlsx file then it's working fine. But I just want to read only the top 5 to 10 lines of .xlsx file. so that's why instead of passing an original file which can be quite large some time greater than 100mb. I am just passing a slice of the file to the FileReader so it can read the file faster otherwise if I pass the original file which can be 100mb then it will take too much time in processing and I do not want to process a whole file to just read top 10 lines.
Here is the code :

onFile(event:any){
let data = event.target.files[0];
let fileReader = new FileReader();
fileReader.onload = (e) => {
  let arrayBuffer = e.target.result;
  console.log(arrayBuffer);
  let workbook = XLSX.read(arrayBuffer, {type:"array"});
  let first_sheet_name = workbook.SheetNames[0];
  let worksheet = workbook.Sheets[first_sheet_name];
  console.log(XLSX.utils.sheet_to_json(worksheet,{raw:true}));
}
fileReader.readAsArrayBuffer(data.slice(0,500));
}

so I think the problem here is during slicing I am trying to slice starting 500 bytes using the slice method and then passing it to the FileReader. so my question is here how can I slice a .xlsx file properly because using the current way file getting corrupt.

Note: other files like .csv or .tsv working fine even if I am slicing them using the current way. I was also able to read the .xlsx file using the same way a few months ago. but I don't know why I am facing this issue now.

about 4 years ago · Juan Pablo Isaza
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