Format property in GridColumnProps is ignored by saveExcel

3 posts, 1 answers
  1. Natasha
    Natasha avatar
    4 posts
    Member since:
    Aug 2019

    Posted 17 Jan Link to this post

    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. Answer
    Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    1187 posts

    Posted 21 Jan Link to this post

    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
  3. Natasha
    Natasha avatar
    4 posts
    Member since:
    Aug 2019

    Posted 21 Jan in reply to Veselin Tsvetanov Link to this post

    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

Back to Top