简体   繁体   English

如何在Kendo UI网格中自定义导出Excel

[英]How to customize export excel in Kendo UI grid

I am using Kendo UI grid. 我正在使用Kendo UI网格。 I have columns and one of these columns has a total amount in the end of column ( footertemplate ). 我有列,并且这些列之一在列末尾有总计(footertemplate)。 when I export to excel, excel Shows total amount 0. I searched on the internet but I dont understand anything. 当我导出到excel时,excel显示总金额为0。我在互联网上搜索,但我什么都不懂。 someone explain simple and help me ? 有人解释简单并帮助我吗? Thank you. 谢谢。

This is my JS code 这是我的JS代码

 self.filterClick = function () { showLoading(); options.columns[7].footerTemplate = 'Toplam: #: data.CreditAmount ? kendo.format("{0:C2}",data.CreditAmount.sum): 0,00 #'; mbisPost('Reports.Summary', "/api/PolisanReportApi/OpenPosOKCItems", ko.toJS(self.filters), function (result) { if (result && result.length > 0) { self.showNoDataToDisplay(false); var kendoResource = getKendoResourceOptions(); $("#grid").kendoGrid({ toolbar: [{ name: "excel", text: kendoResource.toolbar.messages.excel }], excel: { fileName: "OpenPosOKCItemsList.xlsx", allPages: true, filterable: true }, dataSource: { data: result, pageSize: 10, aggregate: [ { field: "CreditAmount", aggregate: "sum" } ] }, groupable: kendoResource.groupable, scrollable: true, sortable: true, selectable: "multiple", pageable: kendoResource.pageable, columns: options.columns }); } else { self.showNoDataToDisplay(true); } }).error(function () { hideLoading(); }).done(function () { hideLoading(); }); } 

这是我的Kendo UI屏幕截图

这是我的Excel屏幕截图

I found the answer. 我找到了答案。

 excelExport: function(e) { var rows = e.workbook.sheets[0].rows; var total = 0; // for (var ri = 0; ri < rows.length; ri++) { var row = rows[ri]; if(row.type == "data"){ total = total + row.cells[7].value; } else 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) { cell.value = "Toplam : " + total; cell.hAlign = "right"; } } } } } 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM