This is a migrated thread and some comments may be shown as answers.

Excel Export - Conditional Formatting?

1 Answer 360 Views
Grid
This is a migrated thread and some comments may be shown as answers.
n/a
Top achievements
Rank 1
n/a asked on 24 Jan 2020, 07:48 PM

I am working on refactoring an old app from Angular 1.2 to Vue. 

I am using the Excel Export feature in the native grid successfully, however in the jQuery (and AngularJS) versions there is an "excelExport" event that we could hook into to modify the workbook prior to it being converted to an actual excel file. We were using this to conditionally apply background colors depending on the value of certain cells. 

Here is an example of our old code:

 

excelExport: function (e) {
            var sheet = e.workbook.sheets[0];
            var statuses = _.object(_.map($scope.dataSource.StatusId, function (x) { return [x.id, { name: x.name, color: x.color }] }));
 
            var statusCol = findExcelColumn(sheet, "Status");
            
            //find status column
            if (statusCol >= 0) {
                //Set status display with colours
                _.each(sheet.rows, function (row) {
                    var value = row.cells[statusCol].value;
                    if (!_.isUndefined(statuses[value])) {
                        row.cells[statusCol].background = statuses[value].color;
                        row.cells[statusCol].value = statuses[value].name;
                    }
                });
            }
        },

 

Is this something that is still possible to do? If not, is it a planned feature? 

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 28 Jan 2020, 09:41 AM

Hello,

Thank you for getting in touch with us.

In Vue Native we pass the data and the setting directly to the saveExcel  function and respectively we can pass the desired setting to the exported file. Yet if you want to have custom cells we will have to use a custom version of the saveExcel function as for example it is done in this example - https://stackblitz.com/edit/ifewhg-l7cehn?file=index.js

Hope this information will be helpful. If you have further questions please let me know.

Regards,
Plamen
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
n/a
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or