我在我的网站上使用Datatables,我试图使一个特定栏目的内容只有在导出为PDF时才加粗。我知道简单的基于文本的格式化可以在指定导出选项的using this method中完成,
exportOptions: {
format: {
body: function ( data, row, column, node ) {
// Strip $ from salary column to make it numeric
return column === 5 ?
data.replace( /[$,]/g, '' ) :
data;
}
}
}但我不明白如何才能将输出设置为粗体。耽误您时间,实在对不起!
发布于 2018-06-21 09:50:49
首先,以JSON格式转储datatable内容。您可以设置表格中任何单元格的内容格式。
摘自PDFMake.org文档
var docDefinition = {
content: [
{
table: {
// headers are automatically repeated if the table spans over multiple pages
// you can declare how many rows should be treated as headers
headerRows: 1,
widths: [ '*', 'auto', 100, '*' ],
body: [
[ 'First', 'Second', 'Third', 'The last one' ],
[ 'Value 1', 'Value 2', 'Value 3', 'Value 4' ],
[ { text: 'Bold value', bold: true }, 'Val 2', 'Val 3', 'Val 4' ]
]
}
}
]
};
pdfMake.createPdf(docDefinition).print()https://stackoverflow.com/questions/50959068
复制相似问题