|
App.component.html
<div class="control-section">
<ejs-grid #grid [dataSource]='data' allowPaging='true' allowTextWrap='true' [textWrapSettings]='wrapSettings' [pageSettings]='pageSettings' [toolbar]='toolbar' (toolbarClick)='toolbarClick($event)' [allowExcelExport]='true'
(excelHeaderQueryCellInfo)='excelHeader($event)'>
|
|
App.component.ts
excelHeader(args: any): void {
let header = args.cell.value.split(' ');
args.cell.value = header.length === 2 ? header[0] + "\n" + header[1]: args.cell.value;
args.style.wrapText = true;
} |
Hi Neo,Greetings from Syncfusion.Query: I want to break header text into two line when excel export is called.By default to break the text into two lines you need to use wrapText property for the particular cell in the excel export. We have prepared sample in that we have used the excelHeaderQueryCellInfo event. Which will be triggered when header cells are created. In that event we have added wrapText as true property in the style argument of the event. And we have also split the header text based on the white space and joined them by concatenating them with “\n”, hence it wraps the combined text in the new line in the excel document. We have shared the sample for your reference.
App.component.html
(excelHeaderQueryCellInfo)='excelHeader($event)'>
App.component.tsexcelHeader(args: any): void {let header = args.cell.value.split(' ');args.cell.value = header.length === 2 ? header[0] + "\n" + header[1]: args.cell.value;args.style.wrapText = true;}Documentation Link: https://ej2.syncfusion.com/angular/documentation/api/grid/#excelheaderquerycellinfoPlease get back to us if you need further assistance.Regards,Balaji Sekar.
|
App.component.ts
toolbarClick(args: ClickEventArgs): void {
switch (args.item.text) {
case 'Excel Export':
let excelExportProperties: any = {
dataSource: orderDetails.slice(0,2)
};
excelExportProperties.dataSource.push({"":""});
this.grid.excelExport(excelExportProperties);
break;
}
}
excelContent(args: any):void{
debugger;
if(Object.keys(args.data).length === 1) {
args.style = { backColor: '#ff704d' };
}
} |