【问题标题】:JsPdf How to add only specific column in a table using JSPdf when we draw HTML table directly to pdfJsPdf 当我们将 HTML 表格直接绘制到 pdf 时,如何使用 JSPdf 在表格中仅添加特定列
【发布时间】:2017-01-12 22:33:13
【问题描述】:

我只想要表格中的特定列,但是这段代码给了我整个表格

var doc = new jsPDF('p', 'pt');
doc.text("From HTML", 40, 50);
var res = doc.autoTableHtmlToJson(document.getElementById("basic-table"));
doc.autoTable(res.columns, res.data, {startY: 60});
doc.save('error_log_report.pdf');

我想要选定的列和 HTML 表格中的相应数据

【问题讨论】:

    标签: jspdf jspdf-autotable


    【解决方案1】:

    doc.autoTableHtmlToJson(); 方法返回您可以过滤的普通 JavaScript 数组。如果你只想要前两列,你可以这样做:

    var res = doc.autoTableHtmlToJson(document.getElementById("basic-table"));
    var columns = [res.columns[0], res.columns[1]];
    doc.autoTable(columns, res.data, {startY: 60});
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-26
      • 1970-01-01
      • 2022-09-28
      • 2020-02-11
      • 2018-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多