1
download() {
    var columns = [
        { title: "Producto", dataKey: "producto" },
        { title: "Fecha", dataKey: "fecha" }
    ];
    var data = [{ "producto": "ddf", "fecha": "cwx" }];
    var doc = new jsPDF('p', 'pt');
    console.log("1", data);
    console.log("2", columns);
    doc.autoTable(columns, data);
    doc.save('table.pdf');            
    //console.log("3", data);
    //this.PdfServiceService.getAll().subscribe(c => {
    //    console.log("4", this.country = c.pdfdata)
    //    this.data = this.country;
    //});  
};

<button (click)="download()">Generate PDF</button>

我想var data通过 JSON 数据传递数据()。我无法将数据传递到 doc auto 表中。这是我尝试过的链接:https ://www.npmjs.com/package/jspdf-autotable

4

1 回答 1

0

只需在数据中添加值并使用数组数组即可[ [],[]]

var columns = ['id', 'Department', 'Joiners', 'Resignations', 'Terminations']

var data= [[1, 'IT',2, 1,0],[2, 'Comp', 1, 0, 0]]
于 2020-01-28T10:24:51.513 回答