jspdf autotable中每列的宽度不同? [英] Different width for each columns in jspdf autotable?
本文介绍了jspdf autotable中每列的宽度不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的表格有13列.如何获得每列不同的宽度?我可以像这样给每列宽度吗?
样式:{overflow:"linebreak",columnWidth:[100,80,80,70,80,80,70,70,70,70,60,80,100]}, >
我的表格语法:
> var res = doc.autoTableHtmlToJson(document.getElementById(tableID));
> doc.autoTable(res.columns, res.data, { styles: {overflow: 'linebreak'
> ,columnWidth: [100,80,80,70,80,80,70,70,70,70,60,80,100]}, startY:
> 60, bodyStyles: {valign: 'top'}, });
解决方案
您必须将columnWidth数组转换为如下形式:
doc.autoTable({
html: '#table',
columnStyles: {
0: {cellWidth: 100},
1: {cellWidth: 80},
2: {cellWidth: 80},
// etc
}
});
请注意使用columnStyles
而不是styles
.
My table has 13 columns. How can I get different width for each column? Can I give each column width like this?
styles: {overflow: 'linebreak' ,columnWidth: [100,80,80,70,80,80,70,70,70,70,60,80,100]},
My table Syntax:
> var res = doc.autoTableHtmlToJson(document.getElementById(tableID));
> doc.autoTable(res.columns, res.data, { styles: {overflow: 'linebreak'
> ,columnWidth: [100,80,80,70,80,80,70,70,70,70,60,80,100]}, startY:
> 60, bodyStyles: {valign: 'top'}, });
解决方案
You would have to transform your columnWidth array to look like this:
doc.autoTable({
html: '#table',
columnStyles: {
0: {cellWidth: 100},
1: {cellWidth: 80},
2: {cellWidth: 80},
// etc
}
});
Note the use of columnStyles
instead of styles
.
这篇关于jspdf autotable中每列的宽度不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文