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

Exporting RadGrid column to Excel

0 Answers 58 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Vitaly
Top achievements
Rank 1
Iron
Iron
Vitaly asked on 23 Jun 2017, 02:16 PM

Hi,

I have a Radgrid with some columns including Time column in format hh:mm:ss:

<telerik:GridBoundColumn HeaderText="POS-CD" DataField="POSCD" UniqueName="POSCD" ReadOnly="True" SortExpression="POSCD" HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" >
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="START-TIME" DataField="STARTTIME" UniqueName="STARTTIME" ReadOnly="True" SortExpression="STARTTIME" HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" DataType="System.String" >
</telerik:GridBoundColumn>

<telerik:GridBoundColumn HeaderText="END-TIME" DataField="ENDTIME" UniqueName="ENDTIME" ReadOnly="True" SortExpression="ENDTIME" HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" >
</telerik:GridBoundColumn>

 

For some reason when RadGrid gets exported to excel columns START-TIME and END-TIME showing spaces.

I try to implemented this code:

if (e.RowType == Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLRowType.DataRow)
{
e.Row.Cells.GetCellByName("STARTTIME").StyleValue = "ttST";
}

 

StyleElement style3 = new StyleElement("ttST");
style3.NumberFormat.FormatType = NumberFormatType.LongTime;
e.Styles.Add(style3);

But it did not work.

Please help me to resolve this problem.

Thanks.

Vitaly.

No answers yet. Maybe you can help?

Tags
General Discussions
Asked by
Vitaly
Top achievements
Rank 1
Iron
Iron
Share this question
or