Completed
Last Updated: 20 May 2022 13:35 by ADMIN
Release R2 2022 SP1
CHEE HANG LIM
Created on: 28 Apr 2022 10:46
Category: GridView
Type: Bug Report
0
RadGridView: GridViewSpreadExport doesn't export as text the header cells when ColumnGroupsViewDefinition is used.

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

Attached Files:
0 comments