Despite the COVID-19 outbreak, our team continues operating at full speed. We are always here to support and answer all your questions.

Feel free to reach out by filling this quick form.

Fill the form
Get Free Trial

Background color for cells in xlsx reports

Answered
Denis asked on September 23, 2020

Hi guys! I have added green color to my cells.

cell.addClass('light-green');

But when I want to export my report to xslx file I dont see these colors. (screen 3, 4)
I’ve checked this example https://jsfiddle.net/flexmonster/v06jx81y/ and I also see that not all colors displaying (screens 1, 2) in xlsx file
Could you help me with this issue?

Attachments:
1.png
2.png
3.png
4.png

4 answers

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster September 23, 2020

Hello, Denis,
 
Thank you for your question.
 
Our team wants to explain that styles added by customizeCell hook are ignored while exporting to Excel.
 
Part of the cells is colored when exporting from the mentioned example because they are styled using CSS. In its turn, the customizeCell API call itself does not affect styling.
 
Please consider using the conditional formatting feature instead of the customizeCell method.
In case you need more general styling, it is possible to use built-in CSS themes/creating your own one.
Both approaches allow preserving formatting after exporting to Excel.
 
We hope it helps.
Please contact us in case other questions arise.
 
Kind regards,
Illia

Public
Denis September 24, 2020

I see, tnx a lot. Just have one question: how works this example with bg-color https://jsfiddle.net/flexmonster/v06jx81y/, some cells are colored with cell.addClass, some not in exported xlsx file, but if I’ll delete this code cell.addClass(“fm-level-“+data.level); and try to export xlsx file all cells will be without colors? Is it mean that cell.addClass(“fm-level-“+data.level) still affects on some cells?

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster September 24, 2020

Hello, Denis,
 
Thank you for your feedback.
 
We want to notice that removing the cell.addClass("fm-level-" + data.level) code snippet does not affect the exported Excel file. Some cells are still colored because their styling is defined directly in the CSS.
 
We hope it helps.
Please contact us in case any other questions arise.
 
Best regards,
Illia

Public
Denis September 28, 2020

Understood. Thank you!

Please login or Register to Submit Answer