0

i have multiple ag grids running under foreach loop , i want to perform excel export and all the data from multiple grids should be exported into single excel within the single sheet. Can someone help me on that . Any help on this will be helpful

1 Answer 1

1

Not sure that I understand your use case:

  1. if your AG Grid instances have different column definitions, then the best solution would be to use an external library which handles the export to excel
  2. if all your grid instances have the same column definitions and only the dataset(rowdata) is different, then you could: a. collect the data from all grids in a single colletion b. create a "headless" AG Grid instance on the fly, pass the columnDefs & rowData and use the exporting mechanism via the API:

    const gridOptions: GridOptions = {
      columnDefs, // shared column defs
      rowData, // aggregated data from all grid instances
    };

    const grid = new Grid(document.createElement('div'), gridOptions);

    gridOptions.api.exportDataAsExcel({
      sheetName: 'Sheet 1',
      fileName: fileName,
    });

    grid.destroy();

Sign up to request clarification or add additional context in comments.

3 Comments

I will make the changes as per your suggestion and will update here if it works , thanks for your answer @andrei_f , you understood the scenario & the col definition are same for all grid .
as of now I created one more grid and kept it hidden and using the excel export of that hidden grid and it is working , and i think that your suggestion for creating a headless grid will also work. Thanks
Glad that it worked for you. Please accept the answer if it solved your problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.