Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

289
Views
Cómo usar el mapa dentro del mapa usando docx npm (javascript)

Estoy tratando de usar el mapa dentro de otro mapa al crear una tabla para un archivo de Word usando el paquete docx de npm.

Se crea el archivo, pero cuando trato de abrirlo en Word dice que el formato de archivo no es compatible. Todo funciona bien si no uso la segunda función de mapa, así que sé que este es el problema.

Esto es lo que tengo:

 export const createTable = (items) => { let loopTables = items.map((item1) => new Table({ columns: 5, width: 0, columnWidths: [2100, 1100, 1100, 1100, 1900], layout: TableLayoutType.FIXED, rows: [ new TableRow({ children: [ new TableCell({ children: [new Paragraph({ children: [ new TextRun({ text: `Main item ${item1[0].Group1}`, }), ] }),], columnSpan: 5, }), ], }), item1.map((item2) => new TableRow({ children: [ new TableCell({ children: [new Paragraph({ children: [ new TextRun({ text: `Nested item ${item2.Group2}`, }), ] }),], columnSpan: 5, }), ], }), ) ] }), ) return loopTables }

loopTables luego se inserta en otro archivo como este:

 { properties: { type: SectionType.CONTINUOUS, }, children: createTable(items) //Here we call the function that generates the table. It works fine without the nested map function. },

¿Alguna idea de qué está mal y qué debo hacer para solucionarlo?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Lo resolvió usando dos bucles for clásicos en su lugar. Las filas se guardaron en dos variables y luego se juntaron en una matriz vacía. Aunque no sé por qué el mapa no funcionó.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!