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

Export Throwing null reference error

Thread ID:





131177 Jun 26,2017 06:30 PM UTC Jun 27,2017 12:39 PM UTC ASP.NET MVC 1
Tags: Grid
Nate Greene
Asked On June 26, 2017 06:30 PM UTC

I am using a the Grid component and have followed the example located here http://mvc.syncfusion.com/demos/web/grid/exportinggrid

this is my razor code for the grid:

                .Datasource(ViewBag.HOMenuItems as IEnumerable<HOMenuItemModel>)
                .ToolbarSettings(toolBar => toolBar.ShowToolbar().ToolbarItems(items =>
                //.ClientSideEvents(e => e.RowSelected("onSelect"))
                .SortSettings(sort => sort.SortedColumns(col => col.Field("Description").Direction(SortOrder.Ascending).Add()))
                .Columns(col =>
                    col.Field("HOItemNumber").HeaderText("HO ID").Width(40).Add();
                    col.Field("Gross Profit").HeaderText("Gross Profit (%)").Format("{0:C2}").Width(40).Add();

and here is the code from the controller for excel exporting:

public void ExportToExcel(string GridModel)
            var dbSetup = new BlueStreakSetupEntities();
            ExcelExport exp = new ExcelExport();
            var DataSource = dbSetup.MenuItems.Where();
            GridProperties obj = ConvertGridObject(GridModel);
            exp.Export(obj, DataSource, "Export.xlsx", ExcelVersion.Excel2010, false, false, "flat-saffron");

WHen I try the export to Excel option I get an Object reference not set to an instance of an object error. It points to the exp.Export() line of the controller code.

Any help would be greatly appreciated.



Mani Sankar Durai [Syncfusion]
Replied On June 27, 2017 12:39 PM UTC

Hi Nate, 

Thanks for contacting Syncfusion support. 

We have analyzed your query and we are able to reproduce the reported issue. To solve the exception that you have faced while exporting the grid please follow the below Knowledge base link. 

Please let us know if you need further assistance. 

Manisankar Durai. 


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

This page will automatically be redirected to the 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