We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Strange behaviour in export to excel from grid

Hello,

When I try to export to excel a grouped grid, captions aggregates are repeated in the grid every time that i press export button.
Excel exported data is right.
I'm attaching two screenshots, before and after export button pressed to see the differences.

This is the code to export:

public onToolbarClick(args: ClickEventArgs): void {
if (args.item.id === 'Grid_excelexport') {
this.grid.excelExport();
}
}


and the grid definition:

<ejs-grid #invoicesGrid id="Grid" [dataSource]="invoices" [allowSorting]="true" [allowMultiSorting]="true"
[allowGrouping]="true" [groupSettings]="groupOptions"
[allowFiltering]="true" [filterSettings]="filterOptions"
[allowExcelExport]="true" [toolbar]="toolbarOptions" (toolbarClick)="onToolbarClick($event)" height="300">
<e-columns>
<e-column field="invoiceCode" headerText="Factura"></e-column>
<e-column field="invoiceDate" headerText="Fecha" format="{ type: 'date', format: 'dd/MM/yyyy' }"></e-column>
<e-column field="partner" headerText="Partner"></e-column>
<e-column field="customer" headerText="Cliente"></e-column>
<e-column field="salesman" headerText="Comercial"></e-column>
<e-column field="projectCode" headerText="Proyecto"></e-column>
<e-column field="quotationCode" headerText="Presupuesto"></e-column>
<e-column field="quotationVersion" headerText="Ver." width="80"></e-column>
<e-column field="amount" headerText="Importe" textAlign="Right">
<ng-template #template let-data>{{ data.amount | currency : 'EUR' : 'symbol' : '.2' }}</ng-template>
</e-column>
<e-column field="gp" headerText="GP" textAlign="Right">
<ng-template #template let-data>{{ data.gp | currency : 'EUR' : 'symbol' : '.2' }}</ng-template>
</e-column>
<e-column field="gpPercentage" headerText="GP %" textAlign="Right" format="P2">
<ng-template #template let-data>{{ data.gpPercentage | percent : '1.2-2' }}</ng-template>
</e-column>
</e-columns>
<e-aggregates>
<e-aggregate>
<e-columns>
<e-column field="amount" type="sum">
<ng-template #groupCaptionTemplate let-data>{{ data.sum | currency : 'EUR' : 'symbol' : '.2' }}</ng-template>
</e-column>
<e-column field="amount" type="sum">
<ng-template #footerTemplate let-data>{{ data.sum | currency : 'EUR' : 'symbol' : '.2' }}</ng-template>
</e-column>
<e-column field="gp" type="sum">
<ng-template #groupCaptionTemplate let-data>{{ data.sum | currency : 'EUR' : 'symbol' : '.2' }}</ng-template>
</e-column>
<e-column field="gp" type="sum">
<ng-template #footerTemplate let-data>{{ data.sum | currency : 'EUR' : 'symbol' : '.2' }}</ng-template>
</e-column>
<e-column field="gpPercentage" type="average">
<ng-template #groupCaptionTemplate let-data>{{ data.average | percent : '1.2-2' }}</ng-template>
</e-column>
<e-column field="gpPercentage" type="average">
<ng-template #footerTemplate let-data>{{ data.average | percent : '1.2-2' }}</ng-template>
</e-column>
</e-columns>
</e-aggregate>
</e-aggregates>
</ejs-grid>

Thanks for your help.
Jose


Attachment: Screenshots_8243d0ac.zip

3 Replies

MS Madhu Sudhanan P Syncfusion Team December 31, 2018 09:31 AM UTC

Hi Jose, 
 
Thanks for contacting Syncfusion support. 

To resolve this problem, you need to call the refreshContentRows method of the content module in the success of the export function as follows. 


public onToolbarClick(args: ClickEventArgs): void { 
    if (args.item.id === 'Grid_excelexport') { 
      this.grid.excelExport().then(() => (<any>this.grid.contentModule).refreshContentRows({})); 
    } 
  } 


Regards, 
Madhu Sudhanan P 



JL Jose Luis Garcia December 31, 2018 09:58 AM UTC

Hi Madhu,

Thank you very much for your help.
Your answer solved aggregate captions but not footer aggregates. The same problem appear in footer.

Do you know how to refresh footer?

Regards and happy new year!!
Jose

Attachment: Screenshot_8f29e23b.zip


MS Madhu Sudhanan P Syncfusion Team December 31, 2018 10:14 AM UTC

Hi Jose, 
 
Thanks for the update. 

Please refer the footer using the below code to resolve this problem. 


public onToolbarClick(args: ClickEventArgs): void { 
    if (args.item.id === 'Grid_excelexport') { 
      this.grid.excelExport().then(() => { 
         (<any>this.grid.contentModule).refreshContentRows({}); 
         (<any>this.grid.aggregateModule).footerRenderer.refresh();  
      }); 
    } 
  } 


Have a happy new year!! 

Regards, 
Madhu Sudhanan P 


Loader.
Live Chat Icon For mobile
Up arrow icon