Export to excel

Export to excel

horus1613horus1613 Posts: 19Questions: 6Answers: 0

Hi!

             {
                extend: 'excelHtml5',

                customize: function(xlsx) {
                    var sheet = xlsx.xl.worksheets['sheet1.xml'];
                    // Loop over the cells in column `E`
                    $('row c[r^="E"] t', sheet).each(function() {
                        if ($(this).text() === 'disable') {
                            $(this).closest('row').children('c').attr('s', '10');
                        }
                    });

                },

                title: 'Клиенты_Доходы',

                exportOptions: {
                    columns: ':visible'
                }

            },

I have 2 questions:
1. How can I change the text color to red in the excel, but don't change the background?
$(this).closest('row').children('c').attr('s', '10');
2. I'm use button "visible columns", and because of this, the desired row does not always turn out to be "E". How can I find it from the header text (for example, "Status")?
$('row c[r^="E"] t', sheet).each(function() {

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @horus1613 ,

    1. I don't think you can change just the colour, you can only choose styles from the list on this page.

    2. The easiest way may be to check the column visibility at the start of the customize function, and work out the lettering from there. Alternatively, the first comment on that page shows how to get the header - so you could also check that.

    Cheers,

    Colin

This discussion has been closed.