Excel exports: how to export all table data without expanding

I currently have a pivot table with export functionality (via an external button as opposed to the tooltip). The export is working fine, however it only exports what is currently within view. 

We have expanded=false set in the dataSourceSettings, so the exported file contains little to no data. How could I go about exporting the entirety of the table's data, regardless of the current, collapsed, view?

Any help on achieving the above would be greatly appreciated


3 Replies

AP AngelinFaithSheeba PaulvannanRajadurai Syncfusion Team April 12, 2022 12:57 PM UTC

Hi Matt Rawlings,


Using beforeExport event, you can export all the data in the pivot table. Kindly refer to the code snippet below.


Code Example:


 

  beforeExport(args) {

    let member = this.pivotObj.dataSourceSettings.drilledMembers;

    this.pivotObj.setProperties(

      { dataSourceSettings: { expandAll: truedrilledMembers: [] } },

      true

    );

    this.pivotObj.engineModule.generateGridData(

      this.pivotObj.dataSourceSettings,

      true

    );

    args.dataCollections = [this.pivotObj.engineModule.pivotValues];

    this.pivotObj.setProperties(

      { dataSourceSettings: { expandAll: falsedrilledMembers: member } },

      true

    );

  }

 

  pdfExport(args) {

    this.pivotObj.pdfExportModule.exportToPDF();

  }

 

  excelExport(args) {

    this.pivotObj.excelExportModule.exportToExcel('Excel');

  }

 

  csvExport(args) {

    var excelExportProperties = {

      fileName: 'csvexport.csv',

    };

    this.pivotObj.excelExportModule.exportToExcel('csv'excelExportProperties);

  }

 


Meanwhile, we have prepared a sample for your reference. Please find it from below link.

Sample: https://stackblitz.com/edit/react-j3ucvt-92v1d2?file=index.js


Also, please refer the following documentation for more details about Exporting and beforeExport event.


Document: Excel Exporting in React Pivot Table component - Syncfusion

Excel Exporting in React Pivot Table component - Syncfusion



Please let us know if you have any concerns.


Regards,

Angelin Faith Sheeba.



MR Matt Rawlings April 13, 2022 05:23 AM UTC

Good morning, 

Thank you kindly for the assistance. 


I've implemented the above with no luck. I still get a 'collapsed' CSV file. 

Is it possible to get a functional component example, as opposed to a class component? As we're using functional components exclusively. 



MM Manikandan Murugesan Syncfusion Team April 15, 2022 10:22 AM UTC

Hi Matt,


We prepared a sample based on your requirements, using react functional components. Please follow the link provided below.


Sample: https://stackblitz.com/edit/react-j3ucvt-hdxhhw?file=index.js


If the problem persists, please reproduce it in the provided sample and revert to us (or) send your sample that replicates the problem. This would allow us to investigate the reported problem at our end and provide a solution as soon as possible.


Regards,

Manikandan


Loader.
Up arrow icon