Error Exporting to Excel

6 posts, 0 answers
  1. Eduardo
    Eduardo avatar
    21 posts
    Member since:
    Aug 2016

    Posted 14 Apr 2017 Link to this post

    Hello All,

    I have the following groupFooterTemplate:

    groupFooterTemplate: '<div style="text-align: right;">#=data.col01.group.value# #=kendo.toString(sum, "n0")#</div>'

     

    It works perfectly, but when I export to Excel, I get the following error:

    VM49544:3 Uncaught TypeError: Cannot read property 'value' of undefined
        at Object.eval [as groupFooterTemplate] (eval at compile (kendo.all.js:194), <anonymous>:3:131)

    What am I doing wrong?

    Cheers.

    Edo.

  2. Stefan
    Admin
    Stefan avatar
    2833 posts

    Posted 18 Apr 2017 Link to this post

    Hello Eduardo,

    Please have in mind that exporting template column is a known limitation of the Grid Excel export feature. In this scenario the used HTML will be exported as well:

    http://docs.telerik.com/kendo-ui/controls/data-management/grid/excel-export#limitations

    If the Grid is exported with a regular template, the values should be exported as expected:

    http://dojo.telerik.com/Aruwu

    If the issue still occurs, please modify the provided example or send a new one reproducing the issue 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 visualization (charts) and form elements.
  3. Eduardo
    Eduardo avatar
    21 posts
    Member since:
    Aug 2016

    Posted 19 Apr 2017 in reply to Stefan Link to this post

    Stefan,

    Thank you for your answer.

    It "almost" works.

    This is my export function:

    excelExport: function (e) {
        console.log("Export starting...");
        var rows = e.workbook.sheets[0].rows;
     
        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) {
                        console.log("DATA: " + cell.value);
                        cell.value = $(cell.value).text();
                        console.log("DATA: " + cell.value);
                        cell.hAlign = 'right';
                    }
                }
            }
        }
    },

     

    This works for a group footer template where I'm not using the group row label, like the following:

    groupFooterTemplate: '<div style="text-align: right;">#=kendo.toString(sum, "n0")#</div>', footerTemplate: '<div style="text-align: right;">#=kendo.toString(sum, "n0")#</div>'

     

    However, it doesn't work in this other template:

    groupFooterTemplate: '<div style="text-align: right;">#=(typeof data.col01.group.value != "undefined" ? data.col01.group.value : "")# #=kendo.toString(sum, "n0")#</div>', footerTemplate: '<div style="text-align: right;">#=kendo.toString(sum, "n0")#</div>'

     

    In this later case, the export function is not called and I get the following error:

    Uncaught TypeError: Cannot read property 'value' of undefined
        at Object.eval [as groupFooterTemplate] (eval at compile (kendo.all.js:194), <anonymous>:3:139)
        at init.<anonymous> (kendo.all.js:11943)
        at d (jquery.min.js:2)
        at Function.map (jquery.min.js:2)
        at init._footer (kendo.all.js:11937)
        at init._dataRow (kendo.all.js:11914)
        at init._dataRows (kendo.all.js:11932)
        at init._dataRow (kendo.all.js:11907)
        at init._dataRows (kendo.all.js:11932)
        at init._dataRow (kendo.all.js:11907)

     

    Is there anything than can be done in this case?

    Cheers.

  4. Stefan
    Admin
    Stefan avatar
    2833 posts

    Posted 21 Apr 2017 Link to this post

    Hello Eduardo,

    I was able to reproduce the same error on my end and it occurs because the group value used in the template is not available for the export.

    I forwarded to our developers' team for further investigation if this is an issue with the export.

    I will provide more information as soon as I receive the report from the team. 

    Thank you in advance for your patience.

    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 visualization (charts) and form elements.
  5. Stefan
    Admin
    Stefan avatar
    2833 posts

    Posted 26 Apr 2017 Link to this post

    Hello Eduardo,

    As this may take more time to investigate I created an issue in our GitHub repository for better visibility.You can track its progress at:

    https://github.com/telerik/kendo-ui-core/issues/3095

    Additionally, I updated your Telerik points for bringing this to our attention.

    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 visualization (charts) and form elements.
  6. Eduardo
    Eduardo avatar
    21 posts
    Member since:
    Aug 2016

    Posted 27 Apr 2017 in reply to Stefan Link to this post

    Stefan,

    Thank you.

    I look forward to the team news.

     

    Edo.

Back to Top