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

How to export aggregate footer and apply outer border on excel data in Angular Grid

Hi,

I am using Grid in my Angular 8 project.

I want to :

          1) export aggregate footer during excel/pdf export, because currently I get only Grid Data(not footer) during excel/pdf export.
          2) Apply outer border on excel data.

Please suggest any way to do that.

Thanks & Regards,
Ankit Pathak

1 Reply

BS Balaji Sekar Syncfusion Team January 29, 2020 05:10 AM

Hi Ankit, 
 
Thanks for contacting us. 
 
Query#1: export aggregate footer during excel/pdf export, because currently I get only Grid Data(not footer) during excel/pdf export. 
 
we suggest you to use the TypeScript way of rendering the aggregates in Grid(as suggested in the below code example), Since angular Ng-template has some technical limitation while compiling the Ng-template. 
 
[App.component.html] 
<div class="control-section"> 
    <ejs-grid #grid [dataSource]='data' allowPaging='true' height=375 [pageSettings]='pageSettings' [aggregates]='aggreagtes'  [toolbar]='toolbar' (toolbarClick)='toolbarClick($event)' 
                [allowExcelExport]='true' [allowPdfExport]='true'> 
. . . 
    </ejs-grid> 
</div> 

[App.component.ts] 
. . . 
export class AppComponent { 
    public data: Object[]; 
    public toolbar: string[]; 
    public pageSettings: Object; 
    public aggreagtes: Object; 
    @ViewChild('grid', {statictrue}) 
    public grid: GridComponent; 
 
    public ngOnInit(): void { 
        this.data = orderDetails; 
        this.toolbar = ['ExcelExport''PdfExport''CsvExport']; 
        this.pageSettings = { pageCount: 5 }; 
        this.aggreagtes = [{ 
            columns: [{ 
                type'Sum', 
                field: 'Freight', 
                format: 'N2', 
                footerTemplate: 'Sum: ${Sum}' 
            }] 
        }]; 
    } 
    } 
} 
 
 
 
Query#2: Apply outer border on excel data. 
 
You can apply the border for excel data using excelQueryCellInfo event of the Grid, which triggers for each cell of the excel export file. Please refer the below code example and sample for more information. 
 
[App.component.html] 
<div class="control-section"> 
    <ejs-grid #grid [dataSource]='data' allowPaging='true' (excelQueryCellInfo)="excelQueryCellInfo($event)" height=375 [pageSettings]='pageSettings' [aggregates]='aggreagtes'  [toolbar]='toolbar' (toolbarClick)='toolbarClick($event)' 
                [allowExcelExport]='true' [allowPdfExport]='true'> 
. . . 
    </ejs-grid> 
</div> 

[App.component.ts] 
. . . 
@Component({ 
    selector: 'app-root', 
    templateUrl: 'app.component.html', 
    providers: [ToolbarServicePageServiceExcelExportServicePdfExportServiceGroupService] 
 
}) 
export class AppComponent { 
    public data: Object[]; 
    public toolbar: string[]; 
    public pageSettings: Object; 
    public aggreagtes: Object; 
    @ViewChild('grid', {statictrue}) 
    public grid: GridComponent; 
 
    public ngOnInit(): void { 
        this.data = orderDetails; 
        this.toolbar = ['ExcelExport''PdfExport''CsvExport']; 
        this.pageSettings = { pageCount: 5 }; 
        this.aggreagtes = [{ 
            columns: [{ 
                type'Sum', 
                field: 'Freight', 
                format: 'N2', 
                footerTemplate: 'Sum: ${Sum}' 
            }] 
        }]; 
    } 
  excelQueryCellInfo(args) { 
// applying the color and border color for  
    args.style = {borders: { color: '#9c4b4b' }, fontColor: '#9c4b4b' }; 
  } 
. . . 
} 
 
 
Please get back to us, if you need further assistance. 
 
Regards, 
Balaji Sekar. 


Loader.
Live Chat Icon For mobile
Up arrow icon