JavaScript
x
21
21
1
const doc = new jsPDF('p', 'pt', 'a4');
2
doc.autoTable({
3
head: headerdata, // array of arrays
4
theme: 'grid',
5
body: bodydata, // arry of arrays
6
startY: doc.autoTable.previous.finalY,
7
Padding: { top: 20, right: 15, bottom: 20, left: 25, },
8
styles: {
9
lineColor: [220, 220, 220],
10
lineWidth: 0.5,
11
overflow: 'linebreak',
12
},
13
willDrawCell: (data) => {
14
if (data.section === 'body' && data.column.dataKey === 2) {
15
doc.setFillColor(239, 154, 154);
16
doc.roundedRect(data.cell.textPos.x + 3, data.cell.textPos.y + 3, data.cell.width, data.cell.height, 5, 5, 'FD');
17
}
18
},
19
headStyles: { fillColor: [249, 249, 251], textColor: [34, 34, 34], },
20
});
21
doc.save('test.pdf');