Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
205 views
in Technique[技术] by (71.8m points)

How to export excel of selected record in Ignite UI in Angular

I am using Ignite UI. In that I am using Igx grid, I am able to export excel of all data using IgxExcelExporterService, but I want to export only selected data by using onRowSelectionChange method of igx grid. Is there any way igx-grid support this functionality?

question from:https://stackoverflow.com/questions/65829595/how-to-export-excel-of-selected-record-in-ignite-ui-in-angular

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can use the Excel Exporter service:

this.excelExportService.exportData(this.data, ..).

Go ahead and pass a data array to the service. How to fill the data array with the selected rows data? Here you can find a code snippet for bootstrapping your POC:

Actual code:

public clicked() {
  let selectedRows = this.grid1.selectedRows;

  for (let rowIndex of selectedRows) {
    let rowData = this.grid1.getRowByIndex(rowIndex).rowData;
    this.exportData.push(rowData);
  }
  console.log(this.exportData);
  this.excelExportService.exportData(this.exportData,
                                     new IgxExcelExporterOptions("ExportedDataFile"));

  this.exportData = [];
}

This Export excel topic will help you any further.

Use this for a starting point with the igxGrid row selection.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...