RadGrid export to excel

exportradgridtelerik

I have a radgrid that generates columns dynamically based on user input. Once the grid is populated, the user has the option to export to excel or word. However when the user want's to retain the page formatting, no data is getting exported. But if the user then selects to ignore paging, everything works fine.

So it seems that if the radgrid property "AutoGenerateColumns" is set to false, and "IgnorePaging" is also false, data isn't getting exported.

Anyone else have this problem or am I over looking something?

Here are the methods that configure and call the export:

    private void ConfigureReport(string strExportType)
    {
        switch (strExportType.ToLower())
        {
            case "excel":
                RadGrid1.ExportSettings.FileName = "RadGridExportToExcel";
                break;

            case "word":
                RadGrid1.ExportSettings.FileName = "RadGridExportToWord";
                break;
        }
        RadGrid1.ExportSettings.IgnorePaging = this.cbxPaging.Checked;
        RadGrid1.ExportSettings.ExportOnlyData = this.cbxFormat.Checked;
    }

    private void btnExcel_Click(object sender, EventArgs e)
    {
        if (this.UserProcess.SearchResults != null &&    
            this.UserProcess.SearchResults.Count > 0)
        { 
            ConfigureReport("excel");
            RadGrid1.MasterTableView.ExportToExcel();
        }
        else
        {
            this.lblError.Text = AAILocalization.GetLocaleText("Error:NoResultExport");
        }
    }

Thanks in advance for the help:)
Pat

P.S. i've excluded the method that creates the columns for bravity's sake.

Best Answer

There isn't enough information here to provide an exact cause/solution, however one suggestion (really more of a workaround) is to always set IgnorePaging when the user is exporting. Here is some sample code:

private void btnExcel_Click(object sender, EventArgs e)
    {
        if (this.UserProcess.SearchResults != null &&    
            this.UserProcess.SearchResults.Count > 0)
        { 
            ConfigureReport("excel");
            RadGrid1.MasterTableView.AllowPaging = false;
            RadGrid1.PageSize = RadGrid1.Items.Count + 1;
            RadGrid1.MasterTableView.ExportToExcel();
        }
        else
        {
            this.lblError.Text = AAILocalization.GetLocaleText("Error:NoResultExport");
        }
    }