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

222
Vistas
How to create 250MB to 750 MBs xlsx file in JavaScript?

I'm trying to create a XLSX file from json, but when I'm trying this code:

const convertJsonToExcel = () => {
    

    //var objeto=JSON.parse(JSON.stringify(jsonData))
    console.log(typeof(bigJson))

    const workSheet = XLSX.utils.json_to_sheet(bigJson['titulo']);
    const workBook = XLSX.utils.book_new();

    XLSX.utils.book_append_sheet(workBook, workSheet, "students")
    // Generate buffer
    XLSX.write(workBook, { bookType: 'xlsx', type: "buffer" })

    // Binary string
    XLSX.write(workBook, { bookType: "xlsx", type: "binary" })

    XLSX.writeFile(workBook, "studentsData.xlsx")
}

I get: FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

This json file is 132MBs, but I'll have files until 250MBs. I looked for ExcelJS library, but it has some issues too : https://github.com/exceljs/exceljs/issues/709

What would be a good strategy?

EDIT:

const convertJsonToExcel = () => {

var arr=bigJson['titulo']

// arr2=arr.slice(arr.length/2, arr.length-1)
// arr=arr.slice(0, arr.length/2)
// arr3=arr.slice(0, 1)

console.log(typeof(bigJson))

const workSheet = XLSX.utils.json_to_sheet(arr);

//XLSX.utils.sheet_add_json(workSheet,arr2,{origin: -1});

const workBook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workBook, workSheet, "students")
XLSX.writeFile(workBook, "studentsData.xlsx")
}

I was trying to create a xlsx file from a json of 500MBs, but it only keeps working without response. This works for 250MBs file.

I tried with the commented part dividing in two blocks the json file, and not getting response again

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

0

Did you try to run your script with params to increase your max heap size? You might reach the heap limit of node.

node --max_old_space_size=4096 app.js

reference: https://nodejs.org/api/cli.html#--max-old-space-sizesize-in-megabytes

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