This is a migrated thread and some comments may be shown as answers.

Format property in GridColumnProps is ignored by saveExcel

2 Answers 157 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Natasha
Top achievements
Rank 1
Natasha asked on 17 Jan 2020, 11:11 AM

Dear Telerik Forum Admins,

 

I would like to format the number columns within my excel export, but it seems that the format string that I am giving (which works in the Grid), is ignored by the saveExcel method when creating the excel. 

 

I attached a snippet of my code and how the same format string works in the Grid.

Could you please advise how I am able to format the numbers within my excel export.

 

Kind regards,

 

Natasha L

2 Answers, 1 is accepted

Sort by
0
Accepted
Veselin Tsvetanov
Telerik team
answered on 21 Jan 2020, 08:39 AM

Hello Natasha,

The Excel export Column options would accept the cell formatting in one of the appropriate for the XLSX formats. Moreover, the format should be passed as a member of the cellOptions field. Having that said, the formatting applied to Grid columns would not be properly understood by the Excel export logic. Here is how the format should be defined instead:

{ 
  field: 'UnitPrice', 
  title: 'Unit Price', 
  cellOptions: { format: "$#,##0.00" } 
}

Here you could find a small StackBlitz sample on the above.

Regards,
Veselin Tsvetanov
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Natasha
Top achievements
Rank 1
answered on 21 Jan 2020, 08:49 AM

Thanks a lot Veselin! It works like a charm and the number in the excel remains a number, which is great!

 

Kind regards,

Natasha L

Tags
General Discussions
Asked by
Natasha
Top achievements
Rank 1
Answers by
Veselin Tsvetanov
Telerik team
Natasha
Top achievements
Rank 1
Share this question
or