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

Grid export to excel no record to display

Thread ID:





120716 Oct 7,2015 05:59 PM UTC Oct 12,2015 04:30 AM UTC ASP.NET Web Forms 4
Tags: Grid
Asked On October 7, 2015 05:59 PM UTC


I'm trying to export to Excel a simple Grid which has a SqlDataSource (declared at design time) as datasource.
The export process seems to run but then the produced Excel file doesn't contain any rows. It only displays 'No Record to display' although header columns are displayed correctly.

I've verified that Syncfusion.EJ.Export, Syncfusion.XlsIO.Base are referenced correctly and invoked in the code behind.

My development environment
Syncfusion ASP.NET used with VS 2013.5 community edition.

My code behind

protected void Page_Load(object sender, EventArgs e)
            Grid1.DataSourceID = SqlDataSource1.ID;

        protected void Grid1_ServerExcelExporting(object sender, Syncfusion.JavaScript.Web.GridEventArgs e)
            ExcelExport xlXport = new ExcelExport();
            xlXport.Export(Grid1.Model, (IEnumerable)Grid1.DataSource, "xlXport.xlsx", ExcelVersion.Excel2013, true, true, ExportTheme.FlatLime);

The Grid declaration in the aspx file:

<ej:Grid ID="Grid1" runat='server' AllowFiltering="true" AllowPaging="true" AllowGrouping="true"
        IsResponsive="true" OnServerExcelExporting="Grid1_ServerExcelExporting" >
        <FilterSettings ShowFilterBarStatus="true" FilterType="Menu" />
        <ToolbarSettings ShowToolbar="true" ToolbarItems="excelExport, pdfExport"></ToolbarSettings>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:XXXXConnectionString %>" SelectCommand="SELECT * FROM [TABLE]"></asp:SqlDataSource>

Thanks in advance

Sellappandi Ramu [Syncfusion]
Replied On October 8, 2015 09:42 AM UTC

Hi Rapops,

Thanks for contacting Syncfusion support.

In the provided code, you are using Grid dataSource directly to Export() method, which is the cause for the issue. 

While setting data source to Grid using sqlDataSource element, the Grid dataSouce will be Null. So it will show the “No records to display” message. Give the list of data to export method and convert SQL data as list data, and use that data in Export() method.

Please refer to the following code example, sample,

protected void FlatGrid_ServerExcelExporting(object sender, Syncfusion.JavaScript.Web.GridEventArgs e)


            ExcelExport exp = new ExcelExport();

            DataView data = (DataView)SqlData.Select(new DataSourceSelectArguments());

            IList data1 = data;

            DataTable dt = data.Table;

            var emp = (from DataRow row in dt.Rows

                   select new Order


                       OrderID = Convert.ToInt32(row["OrderID"]),

                       CustomerID = row["CustomerID"].ToString(),

                       Freight = Convert.ToDouble(row["Freight"]),

                       EmployeeID = Convert.ToInt32(row["EmployeeID"]),

                       ShipCountry = row["ShipCountry"].ToString()


            exp.Export(FlatGrid.Model, (IEnumerable)emp, "Export.xlsx", ExcelVersion.Excel2010, true, true, "flat-lime");

Sample: http://www.syncfusion.com/downloads/support/forum/120716/ze/Sample_120716-599975427

Sellappandi R

Replied On October 9, 2015 08:03 PM UTC

Hi Sellappandi,

Many thanks for your response.

I've rewritten my code as you suggested and it now works. All record exported to Excel.
The provided code sample was of great help!

Many thanks!!


Sellappandi Ramu [Syncfusion]
Replied On October 12, 2015 04:30 AM UTC

Hi Rapops, 

We are happy that the provided suggestion helped you. 

Please get back to us if you need any further assistance.  


Sellappandi R

Sellappandi Ramu [Syncfusion]
Replied On October 12, 2015 04:30 AM UTC

Hi Rapops, 

We are happy that the provided suggestion helped you. 

Please get back to us if you need any further assistance.  


Sellappandi R


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