We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Change the value of a cell for export

Hello, how can I manipulate the value of a grid of the cell, to be exported another value.

Ex. Cell the grid is a checkbox (type bool property), export want it to be shown in the spreadsheet cell, 'Y' or 'N'.


2 Replies

FH Fabio Henrique Baptista August 6, 2015 11:30 AM UTC

Sorry, forgot to mention that I am using "grid.ExportToExcel()"

EM Elavarasan M Syncfusion Team August 7, 2015 06:35 AM UTC

Hi Fabio,

Thank you for using Syncfusion products.

We have analysed your query and you can achieve your requirement to manipulate the cell value while exporting the SfDataGrid into excel by using CellsExportingEventHandler which is used to customize the exporting of particular cell value in Excel.
In the CellsExportingEventHandler, you can change the cell value for export based on the column name, cell type and the actual value of the cell like the below code snippet.

Code Snippet:

var options = new ExcelExportingOptions();           

options.CellsExportingEventHandler = cellsExportingHandler;

private void cellsExportingHandler(object sender, GridCellExcelExportingEventArgs e)


    // Based on the column mapping name and the cell type, we can change the cell values when export to excel.

    if(e.CellType == ExportCellType.RecordCell && e.ColumnName == "IsClosed")


        //if the cellvalue is true, "Y" will be displayed and if the value is false, "N" will be displayed when the grid is exported into excel.

        if (e.CellValue.Equals(true))

            e.Range.Cells[0].Value = "Y";


            e.Range.Cells[0].Value = "N";

        e.Handled = true;


Please refer the below UG documentation link to know about the Excel Exporting in SfDataGrid:

UG link: http://help.syncfusion.com/ug/wpf/index.html#!Documents/exporttoexcel.htm

We have prepared the sample based on your requirement and please find the sample from the following location:

Sample: http://www.syncfusion.com/downloads/support/forum/119844/ze/SfDataGrid_Sample1539655632

Please let us know if this solution helps you.

Elavarasan M

Live Chat Icon For mobile
Up arrow icon