This is a migrated thread and some comments may be shown as answers.

Problem with RadGrid - Export to Excel not working when using Generic List

3 Answers 381 Views
Grid
This is a migrated thread and some comments may be shown as answers.
A Kunte
Top achievements
Rank 1
A Kunte asked on 03 Jun 2011, 11:36 AM

We are binding Generic List of entities (e.g. List<Employee>) with RadGrid (Teleric.Web.UI.dll v2009.2.826.35). We are using GridBoundColumn. Grid gets diplsayed properly. Also it gets exported very well in .pdf and .csv formats. But when we try to export in Excel using ExcelML format, it generates blank excel file. Here is sample code:

 

 

 

 

protected void Page_Load(object sender, EventArgs e)
{
   
}

 

 

 

protected void uxRadListView_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
    SetGridDataSource();
}

 

 

 

public void SetGridDataSource()
{
    uxRadListView.DataSource = GetList();
}

 

 

 

private List<Employee> GetList()
{
    List<Employee> employees = new List<Employee>();
    for (int i = 0; i < 10; i++)
    {
        Employee emp = new Employee();
        emp.EmpId = 100;
        emp.FName = "John";
        employees.Add(emp);
    }
}

 

 

 

protected void uxBtnExport_Click(object sender, EventArgs e)
{
    uxRadListView.ExportSettings.IgnorePaging = true;
    uxRadListView.ExportSettings.OpenInNewWindow = true;
    uxRadListView.ExportSettings.FileName = "EXCEL";

 

 

 

    uxRadListView.ExportSettings.Excel.Format = GridExcelExportFormat.ExcelML;
    uxRadListView.ExportSettings.ExportOnlyData = false;
    uxRadListView.MasterTableView.ExportToExcel();

 

 

 

}

 

 

 

 

 

 

 

 

 

 


Does Telerik support Generic Lists to bind grid? If so, then can somebody help to resolve mentioned issue?. Thank you in advance.

3 Answers, 1 is accepted

Sort by
0
Andreas
Top achievements
Rank 1
answered on 01 Sep 2011, 11:19 AM
Exact same scenario unsing the latest Telerik.Web.UI.dll (2011.2.712.40)

DataSource: Generic List
Every thing works fine except Export to Excel (ExcelML)

I get no error message but the exported Excel File is empty.

I noticed the following behaviors:
  • If Grid is sorted or grouped, the exported Excel contains only the grouped-by and sorted columns (with data).
  • If Export setting is changed to Format="HTML" every thing works fine

Have to mention:
It is not my first implemention of RadGrid with Excel Export feature enabled.
The only difference (after hours of research) compared to my previos implementations is the DataSource type.

Kind regards

Andreas








0
Daniel
Telerik team
answered on 01 Sep 2011, 12:00 PM
Hello Andreas,

Please try to set UseAllDataFields property to true as suggested in the documentation:
ExcelML basics

I hope this helps.

Best regards,
Daniel
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Andreas
Top achievements
Rank 1
answered on 01 Sep 2011, 12:33 PM
Dear Daniel,

thank you very much for your quick response and informations.

Thumbs up, your recommended setting solved my problem!

Best regards

Andreas
Tags
Grid
Asked by
A Kunte
Top achievements
Rank 1
Answers by
Andreas
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or