我想在jsPDF自动表格中使用网格主题添加条纹行。我们如何设置两个主题或在表格中添加css来获得条纹行?我尝试了主题:'grid','striped'。我没有得到任何解决方案。
var doc = new jsPDF('p', 'pt', 'a4');
doc.setFontSize(6);
var elem = document.getElementById("table");
var res = doc.autoTableHtmlToJson(elem);
doc.autoTable(res.columns, res.data, {
margin: {top: 100},
tableLineColor: [189, 195, 199],
tableLineWidth: 0.75,
bodyStyles: {lineColor: [189, 195, 199]},
theme: 'grid',
styles: {
fontSize: 8,
font: 'helvetica',
cellPadding: 2,
minCellHeight: 2,
},
columnStyles: {
0: {cellWidth: 35},
1: {cellWidth: 35},
2: {cellWidth: 185},
3: {cellWidth: 35},
4: {cellWidth: 35},
5: {cellWidth: 184},
},
headStyles: {
fillColor: [255, 255, 255],
textColor: [0, 0, 0],
fontSize: 8,
padding: 0,
},
});
如果你使用新的html选项,你可以使用 useCss
选项来使用css样式。你还可以使用alternateRow选项对每隔一行进行样式设计。对于更复杂的样式,你可以使用钩子。