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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Strange behaviour in export to excel from grid

Thread ID:

Created:

Updated:

Platform:

Replies:

141697 Dec 28,2018 09:18 AM UTC Dec 31,2018 10:14 AM UTC Angular - EJ 2 3
loading
Tags: Grid
Jose Luis Garcia
Asked On December 28, 2018 09:18 AM UTC

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

Madhu Sudhanan P [Syncfusion]
Replied On 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 


Jose Luis Garcia
Replied On 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

Madhu Sudhanan P [Syncfusion]
Replied On 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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;