gpt4 book ai didi

javascript - JsPDF-Autotable空白行使用带有对象的数组

转载 作者:行者123 更新时间:2023-11-29 20:47:39 31 4
gpt4 key购买 nike

我试图用包含人员对象的数组填充表格,clg 显示的结构与插件 github 中的示例相同。我的对象数组: enter image description here

JsPDF- 带有对象的自动数组: enter image description here

我将数组 var 设置为行,但我的表显示如下: enter image description here

表格绘制了 3 行,每个对象一行,但没有显示数据。

这是我的pdf生成器代码

  let genPdf = () => {
var doc = new jsPDF('l', 'pt');
doc.autoTable(cols,rowArray, {
// Styling
theme: 'striped', // 'striped', 'grid' or 'plain'
styles: {overflow: 'linebreak',columnWidth: 'wrap',lineWidth: 1,cellPadding: 2, fontSize: 10 },
columnStyles: { text: { columnWidth: 'auto' } },
headerStyles: {},
bodyStyles: {},
alternateRowStyles: {},

// Properties
startY: 30, // false (indicates margin top value) or a number
margin: 40, // a number, array or object
pageBreak: 'auto', // 'auto', 'avoid' or 'always'
tableWidth: 'auto', // 'auto', 'wrap' or a number,
showHeader: 'everyPage', // 'everyPage', 'firstPage', 'never',
tableLineColor: 200, // number, array (see color section below)
tableLineWidth: 0,

// Hooks

});

doc.setPage(1 + doc.internal.getCurrentPageInfo().pageNumber - doc.autoTable.previous.pageCount);
doc.save('reporte.pdf');}

最佳答案

我必须创建一个数组来保存对象值并像这样推送对象的对象值

arrayWithObjects.push(Object.values(p)); 

p 它是新对象,在 addPerson 函数中我写了上面的代码并工作了 enter image description here

enter image description here

希望对大家有帮助

关于javascript - JsPDF-Autotable空白行使用带有对象的数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53736736/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com