2017-07-19 32 views
0

我的RadGrid中有一個GridDateTimeColumn。我正在使用自定義方法導出到Excel。當我導出日期時導出爲「2/2/2017 1:38:34 tt」。而不是顯示上午或下午,它只是說最後。AM/PM在Excel中顯示爲tt導出

createdColumn.DataFormatString = "MM/dd/yyyy h:mm:ss tt"; 

回答

0

我遇到了同樣的問題。然後我將列的數字格式(顯示日期)更改爲「文本」。這解決了我的問題。

ASPX

<telerik:GridDateTimeColumn HeaderText="Create Date" HeaderStyle-Width="13%" 
    ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" SortExpression="CreateDateDesc" DataField="CreateDate" DataType="System.String" DataFormatString="{0:MM/dd/yyyy hh:mm tt}" ></telerik:GridDateTimeColumn> 

C#

protected void radGrdOrderHistory_InfrastructureExporting(object sender, Telerik.Web.UI.GridInfrastructureExportingEventArgs e) 
{ 
Telerik.Web.UI.ExportInfrastructure.Table tbl = e.ExportStructure.Tables[0]; 
foreach (Telerik.Web.UI.ExportInfrastructure.Cell cell in tbl.Columns[9].Cells) 
    { 
    cell.Format = "@"; 
    } 
} 
+0

你問在回答部分問題。 –

+0

謝謝,@RichaSingh。這工作。 – alicewilliam86

相關問題