如何在ag-grid中启用导出到csv

时间:2016-04-01 16:17:12

标签: ag-grid

我正在使用开箱即用的ag-grid,是否有一个功能可以导出到excel。到目前为止,我还没有写任何事件代码导出到csv。我认为就像它的排序和过滤器功能一样,这也是开箱即用的(例如高图的上下文菜单)。

我是否需要设置一个网格选项,以便为导出到csv或excel

做好准备

感谢

2 个答案:

答案 0 :(得分:5)

当前版本的ag-grid(4.0.7)没有该功能。要完成csv导出,您必须调用ag-grid api函数,例如:

$scope.exportToCsv = function () {
    var params = {
        skipHeader: false,
        skipFooters: true,
        skipGroups: true,
        fileName: "export.csv"
    };
    $scope.gridOptions.api.exportDataAsCsv(params);
}

答案 1 :(得分:0)

要通过右键单击单元格在上下文菜单中的ag-grid(版本20或更高版本)中简单地启用导出。 默认情况下,上下文菜单提供值“复制”和“粘贴”。复制会将选定的单元格或行复制到剪贴板。粘贴将永远永远被禁用。

对于Angular 2及更高版本,请使用此

import { AllModules } from '@ag-grid-enterprise/all-modules'; /* Import AllModules */

@Component({
  selector: 'my-app',
  template: `
    <ag-grid-angular
      #agGrid
      style="width: 100%; height: 100%;"
      id="myGrid"
      class="ag-theme-alpine"
      [modules]="modules"
      [columnDefs]="columnDefs"
      [rowData]="rowData"
      (gridReady)="onGridReady($event)"
    ></ag-grid-angular>
  `,
})
export class AppComponent {
  constructor(){

  }
  public modules: Module[] = AllModules;/*This variable Enable Export in context Menu*/

}

参考:-https://www.ag-grid.com/javascript-grid-context-menu/

相关问题