Can I put for loop inside jsPDF-autotable body?

Viewed 1061

I am having trouble about filling a body of jsPDF-autotable. Can I loop something like this?

 doc.autoTable({ 
                    head: [this.pdf_head],
                    body: [
                            for(let i = 0; i < this.generated_table.length; i++)
                            {
                                for(let j = 0; j < this.generated_column.length; j++)
                                {
                                    [this.pdf_body[i][j]];
                                }
                            }
                        ],
               })

I am using vs-table so I can't use the html format. This code is not currently working but is there a way to do it something like this? Thanks!

1 Answers
let bodyData = [];
for(let i = 0; i < this.generated_table.length; i++)
{
  let rowData = [];
  for(let j = 0; j < this.generated_column.length; j++)
  {
    rowData.push(this.pdf_body[i][j]);
  }
  bodyData.push(rowData);
}

doc.autoTable({ 
    head: [this.pdf_head],
    body: bodyData
})

You can write code like this.

Related