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

Export data to Excel

1 Answer 118 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Liem
Top achievements
Rank 1
Liem asked on 01 Aug 2017, 12:48 AM

Hi,

I have the following grid...

$("#grid").kendoGrid({
            toolbar: ["excel"],
            excelExport: function (e) {
                e.workbook.fileName = "Test.xlsx";
                e.workbook.sheets[0].title = 'Hello World';
              
                var rows = e.workbook.sheets[0].rows;
                e.workbook.sheets[0].rows.unshift({
                    cells: [
                      {
                          value: ''
                      }
                    ],
                });
                e.workbook.sheets[0].rows.unshift({
                    cells: [
                      {
                          value: 'Football: ' + $('input[name=mnuFoot]:checked').val(),
                          bold: true
                      }
                    ],
                });
                e.workbook.sheets[0].rows.unshift({
                    cells: [
                      {
                          value: 'Soccer: ' + $('input[name=mnuSoccer]:checked').val(),
                          bold:  true
                      }
                    ],
    
                });
 
                for (var ri = 0; ri < rows.length; ri++) {
                    var row = rows[ri];

                    if (row.type == "group-footer" || row.type == "footer") {
                        for (var ci = 0; ci < row.cells.length; ci++) {
                            var cell = row.cells[ci];
                            if (cell.value) {
                                 //Use jQuery.fn.text to remove the HTML and get only the text
                                cell.value = $(cell.value).text();
                                //Set the alignment
                                cell.hAlign = "right";
                            }
                        }
                    }
                }
            },

......

How can I export the data using the same functionality as the button on the toolbar using a button outside of the grid?

 

Thanks,

Liem

 

1 Answer, 1 is accepted

Sort by
0
Liem
Top achievements
Rank 1
answered on 01 Aug 2017, 01:33 AM

I found my solution - http://www.telerik.com/forums/export-to-excel-both-single-grid-to-single-file-and-multiple-grid-to-single-file.

 

Thanks all!

Tags
Grid
Asked by
Liem
Top achievements
Rank 1
Answers by
Liem
Top achievements
Rank 1
Share this question
or