excelhtml5 Color predefine
excelhtml5 Color predefine
Hi,
I would like to know if there is a way to add more color or change predefine color. I tried to change fgColor in datatables.js but it doesnt work.
Thanks in advance for helping.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Do you mean the styles identified here? If so, then yes, you can use the
customizecallback method of theexcelHtml5button type to modify the Excel XML. DataTables doesn't define an API for that, you'd need to modify the XML directly.Allan
I've made a testcase to show how to add an extra predefined style.
This code will add a new style that defines a red background and applies it to a specific column and value.
live.datatables.net/redorefa/1/edit
I'd highly recommend to extract the generated .xlsx file and open
xl/styles.xmlto learn what possibilities there are. (the .xlsx file is nothing more than a set of files zipped together)@allan
As a sidenote, the example of adding a different cell background is broken since you define numeric values as a
vnode now, instead of nestedisandt.Perhaps you can add an example based on my testcase for future referece, as it is a recurring question about adding predefined styles.
Thanks for answer i wasnt able to reply earlier
@allan what i meant was just like what HPB said.
@HPB thank you so much for that answer. That is what i searched for.
Hi,
the answer provided by @HPB helps me a lot, but i am not sure how to add multiple colors...this one adds red if condition is true, how do i add green if another condition is true.
I don't get this part : $(this).attr('s', cellXfCount);
Could someone please help me out ?
It is the index of the
cellXfnode. (zero-based)In the testcase I only added 1
cellXfnode, so the index of it was the same as the original amount ofcellXfnodes. Hence I used cellXfCount as the index.If you're adding more styles you should keep track of their index to reference it later in the
sattribute.