728x90
반응형
https://datatables.net/forums/discussion/comment/206900/#Comment_206900
var sSh = xlsx.xl['styles.xml'];
var lastXfIndex = $('cellXfs xf', sSh).length - 1;
var s1 = '<xf numFmtId="300" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>';
//define the style with the new font (number passed in as a variable)
var s2 = '<xf numFmtId="0" fontId="'+(lastFontIndex+1)+'" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyAlignment="1">'+
'<alignment horizontal="center"/></xf>';
var s3 = '<xf numFmtId="0" fontId="2" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyAlignment="1">'+
'<alignment horizontal="center" wrapText="1"/></xf>'
sSh.childNodes[0].childNodes[5].innerHTML += s1 + s2 + s3; //new styles
var fourDecPlaces = lastXfIndex + 1;
var greyBoldCentered = lastXfIndex + 2;
var greyBoldWrapText = lastXfIndex + 3;
$('row:eq(0) c', sheet).attr( 's', greyBoldCentered ); //grey background bold and centered, as added above
$('row:eq(1) c', sheet).attr( 's', greyBoldWrapText ); //grey background bold, text wrapped
728x90
반응형
'Front > JS & jQuery' 카테고리의 다른 글
[datatables] createdCell로 tr에 Class 적용하기 (0) | 2023.10.23 |
---|---|
[echarts]chart click event 적용하기 (0) | 2023.10.12 |
[datatables] excel export style (1) | 2023.10.10 |
[js] spread syntax (0) | 2023.10.09 |
[js] Math.min() / Math.max() (0) | 2023.10.08 |