freeze header row in generated Excel
freeze header row in generated Excel
Hello ~ I am trying to freeze the header row in an Excel file that is being created from a data table. The buttons are defined as follows. I'm looking for the equivalent of FreezePanes() or SplitRow(). Thank you!
buttons: [
{
extend: 'excelHtml5',
text: '<i class="fa fa-file-excel-o"></i>',
className: 'btn-excel',
titleAttr: 'Excel',
filename: 'xxx',
title: function () {if (cboxXXXchecked === true) return 'Active';
else { return 'All'; }
}, selection.
customize: function (xlsx) {
var sheet = xlsx.xl.worksheets['sheet1.xml'];
$('row:eq(0) c', sheet).attr('s', '50'); //50=left aligned
$('row:eq(0) c', sheet).attr('s', '2'); //2=bold
$('row:eq(1) c', sheet).attr('s', '7'); //7=grey background
},
autoFilter: true,
exportOptions: { columns: [0,1,2,3,4,5,6,7,8,9,10,11] }
}
],
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
Answers
This thread should help, it's asking the same thing.
Cheers,
Colin
Thank you! That was exactly what I needed. It took a bit to figure how to change it from freezing the first 3 columns to freezing the top two rows, so I'm posting what worked for me in case it helps the next person...
Super - many thanks for posting your solution.
Allan