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

Excel Export Checkbox column

Hello,

When I export Grid to Excel, the checkbox columns are showing as True or False. I want to show these are Yes or No in the Excel.

Thanks


1 Reply

KK Karthick Kuppusamy Syncfusion Team September 7, 2016 01:20 PM UTC

Hi Arun, 

Thanks for Contacting Syncfusion support. 

We have analyzed your requirement and we can achieve the requirement through the “ServerExcelQueryCellInfo”  event. 


Please find the code example. 

 
@(Html.EJ().Grid<object>("FlatGrid") 
        .Datasource((IEnumerable<object>)ViewBag.dataSource) 
        .AllowPaging() 
        .ToolbarSettings(toolBar => toolBar.ShowToolbar(true).ToolbarItems(items => 
            { 
                items.AddTool(ToolBarItems.ExcelExport); 
                 
            })) 
                .Columns(col => 
            { 
 
                col.Field("OrderID").HeaderText("Order ID").Add(); 
                col.Field("CustomerID").HeaderText("Customer ID").Add(); 
                col.Field("EmployeeID").HeaderText("Employee ID").Add(); 
                col.Field("Verified").HeaderText("Verified").Add(); 
                col.Field("ShipName").HeaderText("ShipName").Add(); 
            }) 
) 
 
public void ExportToExcel(string GridModel) 
        { 
            ExcelExport exp = new ExcelExport(); 
            GridProperties obj = ConvertGridObject(GridModel); 
            var DataSource = OrderRepository.GetAllRecords().ToList(); 
            obj.ServerExcelQueryCellInfo = queryCellInfo; 
            
            exp.Export(obj, DataSource, "Export.xlsx", ExcelVersion.Excel2010, false, false"flat-saffron"); 
 
            
        } 
        
        public void queryCellInfo(object currentCell) {  
            IRange range = (IRange)currentCell; 
            if (range.Column == 4 && range.Value == "TRUE")  
               range.Value = "YES";//assign the value for the Checked value 
            else if(range.Column == 4 && range.Value == "FALSE") 
                range.Value = "NO";// assign the value for the Unchecked value 
        } 



Please find the UG link: 


For your reference we have created a sample based on your requirement and same it can be downloaded from the following location. 


Regards, 
K.Karthick. 


Loader.
Live Chat Icon For mobile
Up arrow icon