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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Excel Export Checkbox column

Thread ID:

Created:

Updated:

Platform:

Replies:

125724 Sep 6,2016 07:21 PM UTC Sep 7,2016 01:20 PM UTC ASP.NET MVC 1
loading
Tags: Grid
Arun Gandhi
Asked On September 6, 2016 07:21 PM UTC

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


Karthick Kuppusamy [Syncfusion]
Replied On 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. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;