combine formating of export excel
combine formating of export excel
f1 = '<font><sz val="12" /><name val="Calibri" /><color rgb="00000" /><b /></font>';
s1 = '<fill><patternFill patternType="solid"><fgColor rgb="213e82" /><bgColor indexed="64" /></patternFill></fill>';
s2 = '<xf numFmtId="168" fontId="1" fillId="6" borderId="1" applyFont="1" applyFill="1" xfId="0" applyAlignment="1"><alignment horizontal="center"/></xf>';
styles.childNodes[0].childNodes[1].innerHTML += f1;
styles.childNodes[0].childNodes[2].innerHTML += s1 + f1;
styles.childNodes[0].childNodes[5].innerHTML += s2;
$('row:first c', sheet).attr( 's', '67' );
code is not working, please help.
Answers
In that code you are not using the fonts, fills and styles you are defining above. So what exactly doesn't work?
There is something wrong in this line:
You are adding a fill and a font to the fills. That shouldn't work.
number formats, fonts, fills and borders are input for styles.
In this code you see the following:
- the last xf-index, i.e. the index of the stlyes is saved and the
- last font index is saved too.
- A new font is defined
- a new number format is defined
- then four new styles are defined that are (also) based ont he new font and the new number format.
- names are assigned to the four new styles, so that those names can be used instead of using a number
due to above code, excel got corrupts. http://live.datatables.net/xoxerowi/3/edit
@rf1234
No, it doesn't. I used your test case and got a non-corrupted Excel export file - even though the code probably doesn't make a lot of sense in the context of your test case.