How to Customize exported excel's cell background color in Datatables
Customize exported excel's cell background color in Datatables
In this post i will walk you through how we can customize exported excel's cell background color in datatables. For this we need make changes in the buttons.html5.js file. you may refer below links for more info. excelHtml5 and how can i change the background color
Follow below steps and make changes in buttons.html5.js file
1. Create your own fills.
'<fills count="11">'+
'<fill>'+
'<patternFill patternType="none" />'+
'</fill>'+
'<fill>'+ // Excel appears to use this as a dotted background regardless of values but
'<patternFill patternType="none" />'+ // to be valid to the schema, use a patternFill
'</fill>'+
'<fill>'+
'<patternFill patternType="solid">'+
'<fgColor rgb="FFD9D9D9" />'+
'<bgColor indexed="64" />'+
'</patternFill>'+
'</fill>'+
'<fill>'+
'<patternFill patternType="solid">'+
'<fgColor rgb="FFD99795" />'+
'<bgColor indexed="64" />'+
'</patternFill>'+
'</fill>'+
'<fill>'+
'<patternFill patternType="solid">'+
'<fgColor rgb="ffc6efce" />'+
'<bgColor indexed="64" />'+
'</patternFill>'+
'</fill>'+
'<fill>'+
'<patternFill patternType="solid">'+
'<fgColor rgb="ffc6cfef" />'+
'<bgColor indexed="64" />'+
'</patternFill>'+
'</fill>'+
'<fill>'+
'<patternFill patternType="solid">'+
'<fgColor rgb="ffc6efcd" />'+
'<bgColor indexed="64" />'+ //6
'</patternFill>'+
'</fill>'+
'<fill>'+
'<patternFill patternType="solid">'+
'<fgColor rgb="ffffeb9c" />'+
'<bgColor indexed="64" />'+ //7
'</patternFill>'+
'</fill>'+
'<fill>'+
'<patternFill patternType="solid">'+
'<fgColor rgb="fffec7cd" />'+
'<bgColor indexed="64" />'+ //8
'</patternFill>'+
'</fill>'+
'<fill>'+
'<patternFill patternType="solid">'+
'<fgColor rgb="ffe3e0cd" />'+
'<bgColor indexed="64" />'+ //9
'</patternFill>'+
'</fill>'+
'<fill>'+
'<patternFill patternType="solid">'+
'<fgColor rgb="ff92d150" />'+
'<bgColor indexed="64" />'+ //10
'</patternFill>'+
'</fill>'+
'</fills>'+
Step 3 does not work
ReplyDelete
ReplyDelete$(this).attr( 's', '40' );
$(this).attr( 's', '45' );
$(this).attr( 's', '35' );
40,45,35 are pre-defined how to define the newly added colors