我找到了解决方案, 在onExcelExport(e:any)中,我可以访问Excel工作表中的单元格并进行编辑 所以我刚刚删除了最后一行 并手动插入我需要的数据 所以代码看起来像这样:
网格设置: <kendo-grid *ngIf="gridData" [data]="gridData" [pageSize]="state.take" [skip]="state.skip" [sort]="state.sort" [filter]="state.filter" filterable="menu" (filterChange)="filterChange($event)" [navigable]="true" (dataStateChange)="dataStateChange($event)" [sortable]="{ allowUnsort: true, mode:'multiple'} " [selectable]="true" (excelExport)="onExcelExport($event)">
<kendo-grid *ngIf="gridData" [data]="gridData" [pageSize]="state.take" [skip]="state.skip" [sort]="state.sort" [filter]="state.filter" filterable="menu" (filterChange)="filterChange($event)" [navigable]="true" (dataStateChange)="dataStateChange($event)" [sortable]="{ allowUnsort: true, mode:'multiple'} " [selectable]="true" (excelExport)="onExcelExport($event)">
功能看起来像这样
onExcelExport(e: any) { // delete last row in the excel sheet const rows = e.workbook.sheets[0].rows; rows.pop(); // push new row by initiate new cell array, looping throw state to get the the right field const cellsSum = []; const rowsLength = rows[rows.length - 1].cells.length; for (let i = 0; i < rowsLength; i++) { const field = this.employeeColumnService.state.employeeDetailsColumns.find(x => x.title === rows[0].cells[i].value.toString()).field; cellsSum.push({value: this.getSum(field)}); } } rows.push({type: "data", cells: cellsSum});