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

MVC 6 Grid Excel Export Problem


I'm using MVC 6 in my project and i'm trying to export grid content using excel option. While debugging, the controller method is hit but nothing happens after the last line.

Kindly help.


        public async Task ExportToExcel(string GridModel)
            var exp = new ExcelExport();

            //Get User Detail
            var user = await GetCurrentUserAsync();

            //Get Grid Datasource
            var dataSource = _repo.GetUserList(user.TeamId);

            //Convert to Grid Object
            var obj = ConvertGridObject(GridModel);

            //Set Properties
            var properties = new GridExcelExport
                FileName = "Export.xlsx",
                Excelversion = ExcelVersion.Excel2010,
                Theme = "flat-saffron",
                LocalSave = true

            //Export Grid
            exp.Export(obj, dataSource, properties);

 private static GridProperties ConvertGridObject(string gridProperty)
            var serializer = new JavaScriptSerializer();
            var div = (IEnumerable)serializer.Deserialize(gridProperty, typeof(IEnumerable));
            var 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)
                    var type = property.PropertyType;
                    var serialize = serializer.Serialize(ds.Value);
                    var value = serializer.Deserialize(serialize, type);
                    property.SetValue(gridProp, value, null);
            return gridProp;


3 Replies

BM Balaji Marimuthu Syncfusion Team May 2, 2016 03:09 PM UTC

Hi Ajay, 
Thanks for contacting Syncfusion support. 
The mentioned issue is occurred due to file access is denied when set the LocalSave option as true in GridExcelExport property, because by default file will be save into the C drive. So, if we set LocalSave as true, we suggest you to use the FilePath in GridExcelExport property. 
var properties = new GridExcelExport 
                . . .  
                Theme = "flat-saffron", 
                FilePath = @"D:\incident", 
                LocalSave = true 
Balaji Marimuthu 

AJ Ajay June 13, 2016 05:29 AM UTC


Thank you. I'm facing another issue with the cell auto-width in exported excel. I've used autofit setting in the grid and hence while exporting the excel contains the cells with 0px width, I need to go to Format menu in Excel and set auto-format width to fix this issue.

Could you help me on this?


IR Isuriya Rajan Syncfusion Team June 15, 2016 12:41 PM UTC

Hi Ajay, 
We have analysed the reported issue with our sample. We are unable to reproduce the issue. 
Please share the following details to find the cause of the issue,   
1.           Can you please provide initial grid render and  controller excelexport method code snippets ?  
2.           Can you please provide the issue reproduced excel sheet? 
3.           Can you please revert us by modifying the sample based on your application along with the replication procedure? 
This would be helpful for us to serve you. 
We have created a sample with exporting and attached for your reference, 
Isuriya R. 

Live Chat Icon For mobile
Up arrow icon