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

Issue with telerik:RadGrid's export to excel method

3 Answers 112 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Joby
Top achievements
Rank 1
Joby asked on 15 Apr 2013, 08:56 PM

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 !!

3 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 18 Apr 2013, 11:23 AM
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.
0
Joby
Top achievements
Rank 1
answered on 18 Apr 2013, 04:40 PM
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?
0
Kostadin
Telerik team
answered on 23 Apr 2013, 08:41 AM
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.
Tags
General Discussions
Asked by
Joby
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Joby
Top achievements
Rank 1
Share this question
or