export to excel with display member

Hi,

How I can export to excel with display member instead value member with dropdownColumns?


1 Reply

VS Vijayarasan Sivanandham Syncfusion Team August 23, 2021 03:04 PM UTC

Hi Jose Leonardo,

Thank you for contacting Syncfusion Support.

The cell value can be customized while exporting to excel by using the CellExporting event of the ExcelExportingOption. Please refer the below code snippet, 
void CellExporting(object sender, Syncfusion.WinForms.DataGridConverter.Events.DataGridCellExcelExportingEventArgs e) 
{ 
            // Based on the column mapping name and the cell type, we can change the cell values while exporting to excel. 
            if (e.CellType == ExportCellType.RecordCell && e.ColumnName == "ShipCityID") 
            { 
                //here get the DisplayMember value by passing ValueMember in GridComboBoxColumn DataSource  
                e.Range.Cells[0].Value = orderInfo.ShipCityDetails[(int)e.CellValue-1].ShipCityName; 
                e.Handled = true; 
            } 
} 

For more information related to Customize Cell Value while Exporting, please refer the below user guide documentation link,

UG Link: https://help.syncfusion.com/windowsforms/datagrid/exporttoexcel#customize-cell-value-while-exporting 
Please let us know if you have any concerns in this.

Regards,
Vijayarasan S


Loader.
Up arrow icon