2017-07-19 4 views
0

J'ai un GridDateTimeColumn dans mon RadGrid. J'utilise une méthode personnalisée pour exporter vers Excel. Lorsque j'exporte la date est exportée en tant que "2/2/2017 1:38:34 tt". Au lieu de montrer AM ou PM, il dit simplement tt à la fin.Affichage AM/PM en tant que tt dans Excel Export

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

Répondre

0

J'avais le même problème. Puis j'ai changé le format numérique de la colonne (qui affichait la date) en "Texte". Qui a résolu mon problème.

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

vous a posé une question à la section de réponse. –

+0

Merci, @RichaSingh. Ça a marché. – alicewilliam86