如何在javascript中使用jsPDF autoTable进行具有多个表的JSON数据的循环

时间:2018-11-17 09:11:38

标签: javascript jspdf-autotable

`

    for (let index = 1; index < res.reportData.length; index++) {

        var doc = new jsPDF('p', 'pt');

        let finalY = doc.autoTable.previous.finalY; 

        doc.autoTable(columns, res.reportData[index].dataValues, {

            styles: {fillColor: [100, 255, 255]},

            pageBreak: 'always',

            columnStyles: {

                id: {fillColor: 255}

            },

            margin: {top: 60},

            addPageContent: function(data) {

                doc.text(res.reportData[index].sensorName, 40, finalY+30);

            }

        });

      sensorName = res.reportData[index].sensorName+'_report';

    }

    doc.save(sensorName+'.pdf');

    only displays last table ..... i don't know exactly how much data          ..... tested with one table table son data works fine ..... once data is of more table overrides and displays only last table

仅显示最后一个表.....我不知道确切多少数据...用一个表测试过的子数据工作正常...一旦数据被更多表覆盖并仅显示最后一张桌子

`

0 个答案:

没有答案