Issue with telerik:RadGrid's export to excel method

4 posts, 0 answers
  1. Joby
    Joby avatar
    2 posts
    Member since:
    May 2011

    Posted 15 Apr 2013 Link to this post

    We have a web page which has a Telerik RadGrid control inside a table structure. We represent text data on the radgrid and the users have the ability to export the data to an excel.

    While exporting the data if any of the cells contains a text ( <number > <letter E > < number) example as '3E7'
    , the exported excel displays this as 3.00E+04 (in excels scientific representation). We tried to address this issue by capturing OnExcelExportCellFormatting method of the radgrid excel export and injecting custom style to the cell.

    Example code below:

                if (e.FormattedColumn.UniqueName == "TierModel")
                    e.Cell.Style["mso-number-format"] = @"00000000";


    Still whenever the radgrid cell contains a data like ( <number > <letter E > < number) , it’s still represented in the scientific way. Is there any way to control the export of these specific text into excel? Any other styles which will solve this issue?

    Also if you have any alternate approaches please let us know.

    Thanks !!

  2. Kostadin
    Admin
    Kostadin avatar
    1733 posts

    Posted 18 Apr 2013 Link to this post

    Hello Joby,

    Thank you for contacting us.

    In order to represent the data as a text in the exported file you have to use the following mso-number-format:
    if (e.FormattedColumn.UniqueName == "TierModel")
      e.Cell.Style["mso-number-format"] = @"\@";

    I hope this information helps.

    All the best,
    Kostadin
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. Joby
    Joby avatar
    2 posts
    Member since:
    May 2011

    Posted 18 Apr 2013 Link to this post

    Thanks Kostadin for your quick response. Even after making the suggested code changes below:

                if (e.FormattedColumn.UniqueName == "TierModel")
                    e.Cell.Style["mso-number-format"] = @"\@";

    the exported excel cell still have the 400E+07 after the changes. The original source text appearing in radgrid cell was '4E7'.

    Any idea what is wrong?
  4. Kostadin
    Admin
    Kostadin avatar
    1733 posts

    Posted 23 Apr 2013 Link to this post

    Hi Joby,

    I prepared a small sample and attached it to this thread. Please give it a try and let me know how it differs from your real setup.

    Regards,
    Kostadin
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top