我想要在数据表导出中使用动态颜色。我有一个按列值查看不同颜色的句柄。如何实现数据表导出?它仅采用内置颜色,如this link提供的那样,但是我想添加深黄色/绿色,因此无法在导出中添加它。
我尝试使用
添加自定义颜色$(this).attr('background-color', '#66FF33');
// and also
$(this).css('background', '#66FF33');
虽然没有用。
var table = $('#OperationDataTable').DataTable({
"stripeClasses": ['odd-row', 'even-row'],
"lengthMenu": [10, 25, 50, 100, 150],
"pageLength": 50,
"aaSorting": [],
responsive: true,
fixedHeader: false,
dom: 'lfBrtip',
buttons: [{
// 'excel'
extend: 'excelHtml5',
customize: function(xlsx) {
var sheet = xlsx.xl.worksheets['sheet1.xml'];
$('row:first c', sheet).attr('s', '42');
$('row c[r^="D"]', sheet).each(function() {
if ($('is t', this).text() == "Negative NFE") {
$(this).attr('s', '20');
//$(this).attr( 'background-color', '#66FF33' );
} else if ($('is t', this).text() == "Online Done") {
} else {
$(this).attr('s', '34');
}
});
}
}]
});
或其应如数据表视图中所示导出(表示html / css)