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

Grid export to excel - how to format cells as text?

3 Answers 875 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kelly
Top achievements
Rank 1
Kelly asked on 14 Apr 2009, 04:16 PM
Is there a setting I can change so that the columns are formatted as text in the exported Excel document?

I'm exporting the RadGrid to excel using the following settings.  When I have a large number without dashes (for example a 13-digit ISBN like 9780071447997, it shows up as scientific format in the excel file (9.78007E+12).   It would be a lot more user-friendly if the value is exported without any modification (i.e., format all values as text). 

 <ExportSettings ExportOnlyData="true">
            <Excel Format="Html" />
        </ExportSettings>

 

string filename = "OrderImport";

 

MessageGrid.ExportSettings.FileName = filename;

MessageGrid.ExportSettings.IgnorePaging =

true;

 

MessageGrid.ExportSettings.OpenInNewWindow =

true;

 

MessageGrid.MasterTableView.ExportToExcel();

3 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 15 Apr 2009, 07:37 AM
Hiello Kelly,
 
You can either add &nbsp; (as shown below) or use the ExcelExportCellFormatting event to format your data.
<telerik:GridBoundColumn  
    DataFormatString="&nbsp;{0}"   
    DataField="Id"
</telerik:GridBoundColumn>  

mso-number-format

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Kelly
Top achievements
Rank 1
answered on 16 Apr 2009, 05:01 PM
Thanks, the &nbsp; trick worked.  Is the cell formatting event new?  I don't see it in Intellisense (I am using Telerik.Web.UI version 2008.2.723.20)
0
Daniel
Telerik team
answered on 17 Apr 2009, 05:50 PM
Hello Kelly,

The mentioned event was added in RadControls for ASP.NET AJAX Q2 2008 SP1 (version 2008.2.826) .

Let us know if you need more information.

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Kelly
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Kelly
Top achievements
Rank 1
Share this question
or