Run the attached project and click List then Export.
Expected:
Actual:
Workaround:
Private Sub RadButton2_Click(sender As Object, e As EventArgs) Handles RadButton2.Click
Dim spreadExporter As GridViewSpreadExport = New GridViewSpreadExport(gvAssetSchedule)
AddHandler spreadExporter.CellFormatting, AddressOf spreadExporter_CellFormatting
Dim exportRenderer As New SpreadExportRenderer()
spreadExporter.ExportVisualSettings = True
Dim filename = "..\..\export" & DateTime.Now.ToLongTimeString().Replace(":", "_") & ".xlsx"
spreadExporter.RunExport(filename, exportRenderer)
Process.Start(filename)
End Sub
Private Sub spreadExporter_CellFormatting(sender As Object, e As Telerik.WinControls.Export.CellFormattingEventArgs)
If e.GridCellInfo Is Nothing Then
Dim selection As CellSelection = e.CellSelection
Dim range As CellRange = selection.CellRanges(0)
Dim val = selection.Worksheet.Cells(range.FromIndex.RowIndex, range.FromIndex.ColumnIndex).GetValue()
Dim format As New CellValueFormat("@")
selection.Worksheet.Cells(range.FromIndex.RowIndex, range.FromIndex.ColumnIndex).SetFormat(format)
Dim dt As New DateTime(1900, 1, 1)
Dim parsedDays = 0
If Integer.TryParse(val.Value.RawValue, parsedDays) Then
dt = dt.AddDays(parsedDays)
selection.Worksheet.Cells(range.FromIndex.RowIndex, range.FromIndex.ColumnIndex).SetValue(dt.Year & "-" & MonthName(dt.Month))
End If
End If
End Sub