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

845
Vistas
Using ExcelJS, how to read data from excel file using URL?

I have excel file upload in cloud. Using node js when front end pass URL i need to read data from excel file. Below is my code,

  var workbook = new ExcelJS.Workbook(); 
  workbook.xlsx.load('https://file-examples.com/wp-content/uploads/2017/02/file_example_XLSX_10.xlsx')
    .then(function() {
        var worksheet = workbook.getWorksheet(sheet);
        worksheet.eachRow({ includeEmpty: true }, function(row, rowNumber) {
          console.log("Row " + rowNumber + " = " + JSON.stringify(row.values));
        });
    });

But I'm getting this error,

Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html

Can someone help me to fix this?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Fixed using the below code.

const axios = require("axios");
const XLSX = require("xlsx");
const jsontoxml = require("jsontoxml");

async function testAxiosXlsx(url) {
    const options = { 
        url,
        responseType: "arraybuffer"
    }
    let axiosResponse = await axios(options);
    const workbook = XLSX.read(axiosResponse.data);

    let worksheets = workbook.SheetNames.map(sheetName => {
        return { sheetName, data: XLSX.utils.sheet_to_json(workbook.Sheets[sheetName]) };
    });

    console.log("json:\n", JSON.stringify(worksheets), "\n\n");
    console.log("xml:\n", jsontoxml(worksheets, {}));
}

testAxiosXlsx("https://file-examples.com/wp-content/uploads/2017/02/file_example_XLSX_10.xlsx");
about 4 years ago · Juan Pablo Isaza Denunciar

0

Look at the documentation.

The load method expects you to pass a Buffer containing Excel data.

You are passing it a string, and that string contains a URL, not Excel data.

You need to fetch the data and convert it to a buffer.

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