How to add styling to cell (font color,size,background color etc) to XLSX
-
How can I go about adding custom styling to the row/cell? I see that I can do <c s="9" r="E{{#sum items.length }}{{/sum}}" t="str"><f>SUM(E2:E{{#getPPSubtotal}}{{/getPPSubtotal}})</f></c> and if I change it to s="3" for example, it will change the color, but where could I define that?
-
hi @jabren unfortunately i don't have any specific recommendation here.
you will need some knowledge about how Open XML stores styles in order to do what you want, i recommend to you read this http://officeopenxml.com/SSstyles.php to know what is the format, where should they live, and how to apply the styles.
-
@bjrmatos Could please tell me how can I add styles.xml? I need that file to define new styles.
-
Ok, I've found a solution. We have to replace styles.xml file with our own definition.
{{#xlsxReplace "xl/styles.xml"}} <stylesheet xmls="http://schemas.openxmlformats.org/spreadsheetml/2006/main"> <numFmts/> <fonts/> <fills/> <borders/> <cellStyleXfs/> <cellXfs/> <cellStyles/> <dxfs/> <tableStyles/> </stylesheet> {{#xlsxReplace "xl/styles.xml"}}`
-
even after I added
<fill>.....
I still don't know how to apply it to cell:
<c t="inlineStr" fillId="3" ><is><t>{{val}}</t></is></c>
is not the way to go :(
-
i added an answer here
https://stackoverflow.com/a/62287482/6945325