Remove HTML from Excel generated from Kendo Grid

前端 未结 1 1937
天命终不由人
天命终不由人 2021-01-26 12:38

I\'m using the following code to load grid data and for removing the HTML from the footer and group footer in Excel. I\'m using the recommended code only but somehow it\'s not w

1条回答
  •  失恋的感觉
    2021-01-26 13:00

    In your demo, the jQuery text() function is causing a javascript error. Use a regular expression replacement instead:

        $("#grid").kendoGrid({
            toolbar: ["excel"],
            excelExport: function(e) {
              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) {
                      if (cell.value.indexOf(" -1) {
                        var val = cell.value.replace(/<(?:.|\n)*?>/gm, '');
                        cell.value = val;
                      }
                      cell.hAlign = "right";
                    }
                  }
                }
              }
            },
            excel: {
                fileName: "Kendo UI Grid Export.xlsx",                  
                proxyURL: "https://demos.telerik.com/kendo-ui/service/export",
                filterable: true
            },
    

    Updated DEMO

    0 讨论(0)
提交回复
热议问题