- Home
- Forum
- Angular - EJ 2
- Aggregates of custom type are being exported as string
Aggregates of custom type are being exported as string
Hi, i'm using grid excel export functionality, of version "22.1.34"
Hi Usman Ali,
Greetings from Syncfusion support.
By default, Grid aggregate values are maintained as strings, displaying along with the aggregate type (min, max, sum, aggregate). Consequently, these values are returned and exported as strings, which is the expected behavior. However, you we have provided a sample-level customization based on your requirement. Please refer to the following code example and sample, where we customized the aggregate values of the Sales column in the excelAggregateQueryCellInfo event of the Grid. In this event we have parsed the string to number using parseFloat method for percentage format by replacing the % symbol however for numeric format you can directly parseFloat the value.
|
App.component.ts
excelAggregateQueryCellInfo(args: any): void { if (args.cell.column.field === 'Sales') { if (args.style.value.includes('%')) { let newvalue = parseFloat(args.style.value.replace("%", "")); // converting the string to number. args.style.value = newvalue / 100; // Converting to original value from percentage value. } } }
|
|
App.component.html
<ejs-grid #grid id='DefaultExport' [dataSource]="data" [allowSorting]='true' [enableHover]='false' [allowMultiSorting]='true' [allowFiltering]='true' [filterSettings]='filterSettings' [aggregates]='aggregates' [toolbar]='toolbar' height=300 [gridLines]="gridLines" [allowExcelExport]='true' [allowPdfExport]='true' (toolbarClick)='toolbarClick($event)' (excelAggregateQueryCellInfo)='excelAggregateQueryCellInfo($event)'> <e-columns> ………………………………………. </e-columns> </ejs-grid>
|
Screenshot:
API Reference: excelAggregateQueryCellInfo
If you need any other assistance or have additional questions, please feel free to contact us.
Regards
Aishwarya R
It's working. Thank you so much for the help.
👍
Hi Usman Ali,
You’re most welcome. We are happy to hear that the provided solution was helpful. Please get back to us if you need any other assistance.
Regards
Aishwarya R
- 3 Replies
- 2 Participants
-
UA Usman Ali
- Oct 14, 2024 09:31 AM UTC
- Oct 17, 2024 10:33 AM UTC