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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

ExportToExcel Filter

Thread ID:





118880 Apr 19,2015 07:46 AM UTC Oct 28,2015 12:57 PM UTC ASP.NET MVC 3
Tags: Grid
Asked On April 19, 2015 07:46 AM UTC

i have a problem trying to export grid to excel .
            .Datasource("odata/ODATACustomers/").ToolbarSettings(toolbar =>
                toolbar.ShowToolbar().ToolbarItems(items =>
            }).Mappers(map => map.ExportToExcelAction("Customers/ExcelAction"))
        .PageSettings(page => { page.PageSize(9); })
        .Columns(col =>
            col.Field("A").HeaderText("Order ID").IsPrimaryKey(true).IsIdentity(true).TextAlign(TextAlign.Right).Width(75).Add();
        }).AllowFiltering().FilterSettings(filter => { filter.FilterType(FilterType.Excel); }).AllowSorting().IsResponsive(true)
the controller action

        public void ExcelAction(string GridModel)
            ExcelExport exp = new ExcelExport();
            var DataSource =  db.Customers.ToList();
            GridProperties obj = ConvertGridObject(GridModel);
            exp.Export(obj, DataSource, "Export.xlsx", ExcelVersion.Excel2010,false, false, "flat-saffron");

        private GridProperties ConvertGridObject(string gridProperty)
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            IEnumerable div = (IEnumerable)serializer.Deserialize(gridProperty, typeof(IEnumerable));
            GridProperties gridProp = new GridProperties();
            foreach (KeyValuePair<string, object> ds in div)
                var property = gridProp.GetType().GetProperty(ds.Key, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase);
                if (property != null)
                    Type type = property.PropertyType;
                    string serialize = serializer.Serialize(ds.Value);
                    object value = serializer.Deserialize(serialize, type);
                    property.SetValue(gridProp, value, null);
            return gridProp;

the export functionality works when there are no filters set on the grid. As i set a filter on any column the ConvertGridObject doesn't get any DataSource property . This makes the gridProperties parameter passed to the Export function skip all the records.

where is the error in the above code ? did i missed any additional property ? i searched on the forum but i found nothing helpful. 

the only related post was 


but the link is broken.

Prasanna Kumar Viswanathan [Syncfusion]
Replied On April 20, 2015 07:06 PM UTC

Hi Xenon,


Thanks for contacting Syncfusion support.


We have analyzed your query and we have internally created a sample with OData and tried exporting it. It is exported correctly as expected also we were unable to reproduce the reported issue.


We request you to share more information on this issue. Please let us know, whether you were unable to get the ‘filtered record’ or it shows 'no records’ while exporting.


We need more information on the reported issue that you are facing with “OData exporting” along with the issue replication procedure and working scenario. We would appreciate if you provide more details like screenshot / video / error reproducing sample will be helpful for us to proceed further.



Prasanna Kumar

Nguyen Hoai Nam
Replied On October 27, 2015 08:10 AM UTC


I have a similar problem, when export without fitler, It's working fine, but when I filter more 2 condition, I have no data or fire exception:

My code: 
 public void ExportToExcel(string gridModel)
            GridExcelExport gridExp = new GridExcelExport();

            ExcelExport exp = new ExcelExport();
            IEnumerable dataSource = DieuDongThietBiContext.GetAllEquipmentByDepartment(); //Return list of object. It the same with datasource in view.
            GridProperties obj = ConvertGridObject(gridModel);
            exp.Export(obj, dataSource, "Export.xlsx", ExcelVersion.Excel2010, false, false, "default-theme");

Note: I also test in sample project and try to filter before exporting, but I don't work, too. Please view attachment!

Attachment: Sample135423_901f3ff3.zip

Prasanna Kumar Viswanathan [Syncfusion]
Replied On October 28, 2015 12:57 PM UTC

Hi Xenon,

We tried with the attached sample and we can export with filtered records in excel. So, please confirm the following details.

1. In the attached screenshot, according to the call stack the issue is reproduced while performing sorting operation.

2. Ensure that you are able to get the data in the controller.

3. We suggest you to add a break point in the export function and ensure that you able to get the sorted columns in the obj.

Please find the screenshot:

4. Essential Studio version details.

For your convenience, we attached a video while exporting and please download the video from the following link

Link: http://www.syncfusion.com/downloads/support/forum/118880/ze/Video1157328958         


Prasanna Kumar N.S.V


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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

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