Export Grid numbers on currency format

When the grid is exported, the excel file has this warnings on numbers cells.

So, to avoid this we clean the format to have just a numbers like this:

But what we need is having the currency format and the number formats. Like if you had added it from excel options.

Is there a way to expor the grid with the numbers columns as a currency format?

 


1 Reply

RR Rajapandi Ravi Syncfusion Team July 14, 2022 01:42 PM UTC

Hi Hiram,


Greetings from Syncfusion support


We have analyzed your query and we could see that you like to export the currency format to the excel document. You can achieve your requirement by using excelQueryCellInfo event of the Grid. In that event you can formatting grid columns value to the corresponding currency format as you want. Please refer the below code example and sample for more information.


 

<ejs-grid #grid [dataSource]='data' (toolbarClick)='toolbarClick($event)' [toolbar]='toolbar' locale='en-US' [allowExcelExport]='true' (excelQueryCellInfo)='exportQueryCellInfo($event)' allowPaging='true' height=365 [pageSettings]='initialPage'>

        <e-columns>

      .  .  .  .  .  .  .  .  .  .  .  .  .

      .  .  .  .  .  .  .  .  .  .  .  .  .

        </e-columns>

    </ejs-grid>


 

exportQueryCellInfo(args) { //excelQueryCellInfo event

        if (args.column.field === "Freight") {

            var usdollars = Intl.NumberFormat("en-US", {

                style: "currency",

                currency: "USD",

            });

            args.value = usdollars.format(args.data['Freight'])

        }

    }

 


Sample: https://stackblitz.com/edit/angular-bbbvxa?file=app.component.ts,app.component.html,data.ts


API: https://ej2.syncfusion.com/angular/documentation/api/grid/#excelquerycellinfo


Regards,

Rajapandi R


Loader.
Up arrow icon