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

610
Vistas
How to set excelsheet row height to auto so that the content can autofit in the cell using exceljs

I am using exceljs npm to export data in excelsheet. As my content in the cell is huge so I wanted text to be wrapped in the cell and should take enough height to show full content. I tried by giving fixed width -

worksheet.getRow(1).height = 20;

The problem with fixed height is that if my content is large than this size then it won't fit in the cell and it shows cropped text like shown in the screenshot.

enter image description here

I wanted cells to look like this enter image description here

I have gone through the exceljs documentation but didn't find anything.

Thanks in advance !!

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

Have you already tried not to define the height of the row? I had the same problem and I solved it like this and that way the height of the row adjusts automatically.

I hope the solution I applied in my case is useful to you. Greetings.

over 4 years ago · Santiago Trujillo Denunciar

0

what worked for me was ,

worksheet.addRow(temp);
const row = worksheet.lastRow;
row.getCell(3).alignment = { wrapText: true };

when ever a new row is added, that rows 3rd cell alignment has to be set.

or

once all the rows are added in that sheet , iterated over all the rows and set the alignment property.

over 4 years ago · Santiago Trujillo Denunciar

0

You can do something like this: Foreach on your data and get the desired row through the index

const row = worksheet.getRow(index);
    row.height = row.height * 20 / row.width;

*NOTE:

  • I fixed the number '20', but you can also make it a variable

  • In my excel, my data data starts at line four onwards, so I do:

     const row = worksheet.getRow(index + 4);
    
over 4 years ago · Santiago Trujillo 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