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

Grid Export to Excel Error .saveAsExcel()

1 Answer 1980 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dennis
Top achievements
Rank 1
Dennis asked on 07 Feb 2017, 10:48 PM

I'm getting the following error when trying to call the method .saveAsExcel(): "Unable to get property 'length' of undefined or null reference"

Here is code:

$(".download-excel").on("click",
    function() {
        try {
            var grid = $("#DataGrid").data("kendoGrid");
            grid.saveAsExcel();
        } catch (e) {
            fnDialog('Error Exporting Excel',
                'There was an error exporting the excel document. Please contact customer service.',
                null,
                null);
        }
    });

 

If I set a watch on the grid object, I can see the data. For some reason it fails at the grid.saveAsExcel();

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 09 Feb 2017, 12:27 PM
Hello Dennis,

This is not a known issue and it was not reproduced in my testing scenario.

I made an example using similar implementation and the Grid was correctly exported to Excel:

http://dojo.telerik.com/eMoqe

If I missed an important detail, please modify the provided Dojo and I will gladly assist.

Regards,
Stefan
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data (charts) and form elements.
Karl Williams
Top achievements
Rank 2
commented on 05 Aug 2022, 08:56 PM

I'm getting the same error. I have the jszip library in the right place and the tool bar button works. The saveAsExcel() function fails with the following error:

Cannot read properties of undefined (reading 'saveAsExcel')

Here's my code:

function ExportExcel() {
try {
var grid = $("#AssetGrid").data("kendoGrid");
grid.saveAsExcel();
} catch (error) {
alert(error);
}
}
Georgi Denchev
Telerik team
commented on 09 Aug 2022, 09:19 AM

Hello, Karl,

I tested the Dojo that was provided by my colleague with the latest version of Kendo UI, however it is still working properly.

http://dojo.telerik.com/oRATIhAj 

The error seems to indicate the variable "grid" is undefined. This usually means that the $("#AssetGrid") selector has not found the Grid element. I would recommend that you double-check the name of the id and make sure there are no typos.

In case this doesn't help, could you modify the Dojo to reproduce the error and send it back to me?

Best Regards,

Georgi

Tags
Grid
Asked by
Dennis
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or