RadGrid Excel中的DateTime列以军事时间导出

时间:2014-08-19 16:29:51

标签: vb.net telerik radgrid

所以我有一个RadGrid,它有一个DateTime列。在网格中它将显示为12/31/13 12:00:00 AM,这是完美的。但是当我导出到Excel时,它显示为12/31/13 0:00。

有没有办法在VB.NET中改变它,或者我应该在军事时间处理它?<​​/ p>

1 个答案:

答案 0 :(得分:1)

尝试从下面的C#解决方案中获取的代码:

http://www.telerik.com/forums/radgrid-export-to-excel-date-format

您显然需要将ExcelExportCellFormatting事件添加到RadGrid并修改&#34; UniqueName&#34;到你的DateTime列的单一序列。

Protected Sub RadGrid1_ExcelExportCellFormatting(source As Object, e As ExcelExportCellFormattingEventArgs)
  If (e.FormattedColumn.UniqueName) = "UniqueName" Then
    e.Cell.Style("mso-number-format") = "m\/d\/yy\ h\:mm\ AM\/PM"
  End If
End Sub