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

Multi-line cell in Excel export

1 Answer 47 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Susan Shaw
Top achievements
Rank 1
Susan Shaw asked on 07 Aug 2012, 11:41 PM
I'm exporting my radgrid to Excel, that part is working great.  What I'm having trouble with is one of the columns in the gridview is a listbox, so in my export, I want to export the list.  I do have that working correctly, I'm getting all items in the list.  Where I'm stuck is I want each item in the list to be on a different line in the Excel cell, so when it exports and I open Excel I want to see

Item A
Item B
Item C

what I currently get is Item A Item B Item C

Below is my code, is there something obvious I'm missing to accomplish this?

if

 

 

(e.Element == ExportElement.Cell)

 

{

 

 

if (e.Value is SurveyDetail)

 

{

 

 

SurveyDetail surveyDetail = (SurveyDetail)e.Value;

 

 

 

if (e.Context is Telerik.Windows.Controls.GridViewDataColumn)

 

{

Telerik.Windows.Controls.

 

GridViewDataColumn dc = (Telerik.Windows.Controls.GridViewDataColumn)e.Context;

 

 

 

if (dc.Name == "dcCPUJobCode")

 

{

 

 

StringBuilder sb = new StringBuilder();

 

 

 

foreach (CPUJobCode cpuJobCode in surveyDetail.SurveyJobCode.CPUJobCodes)

 

{

sb.Append(

 

string.Format("{0} {1} \n", cpuJobCode.JobCode, cpuJobCode.JobTitle));

 

}

e.Value = sb.ToString();

}

}

}

}

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 08 Aug 2012, 05:50 AM
Hello,

 If this is HTML export format you can use <br /> instead \n.

Regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Susan Shaw
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or