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

[Solved] Export data from Grid Prometheus to MS Excel

5 Answers 349 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vinhlan
Top achievements
Rank 1
Vinhlan asked on 11 Mar 2008, 12:33 AM
I've got an issue when exporting data to MS excel:

-the order of the columns are from the dataset that the grid bind to, not the order of the columns displayed in the dataset

below are the code snipet:

  protected void ImgExportExcel_Click(object sender, ImageClickEventArgs e)
    {

        rdgLUValue = ConfigureExcelExport(rdgLUValue);

        bindLookupDataForExport();

        rdgLUValue.MasterTableView.ExportToExcel();
    }

 
    public RadGrid ConfigureExcelExport(Telerik.Web.UI.RadGrid grdDataGrid)
    {
        grdDataGrid.ExportSettings.IgnorePaging = true;
        //grdDataGrid.AllowPaging = false;
        grdDataGrid.ExportSettings.ExportOnlyData = true;
        grdDataGrid.ExportSettings.Excel.Format = Telerik.Web.UI.GridExcelExportFormat.ExcelML;
       
        return grdDataGrid;
    }

   private void bindLookupDataForExport()
    {
        if (BAtEase.Common.BAtEaseSession.LookupData != null)
        {
            rdgLUValue.DataSource = BAtEase.Common.BAtEaseSession.LookupData;
            rdgLUValue.DataBind();
            up.Update();
        }

    }

Please, help.
Thanks.

5 Answers, 1 is accepted

Sort by
0
Mark Hubert
Top achievements
Rank 1
answered on 11 Mar 2008, 05:28 AM
Hi,

In addition:

1) The column names from the datasource are exported, not the grid headertexts.

2) All columns from the datasource are exported, not only the ones visible in the grid. This is especially a problem where some (invisible) columns contain guids and other columns contain 'metadata' for gridhyperlinkcolumns.

Regards,
Mark
0
Maria Ilieva
Telerik team
answered on 13 Mar 2008, 11:07 AM
Hello Mark van Zelst,

I reviewed your code and found that there are some incorrect settings in the Grid binding. The approach, you have tried to use, could not be implement in this way:
rdgLUValue.DataSource = BAtEase.Common.BAtEaseSession.LookupData;
            rdgLUValue.DataBind();

In your scenario you should rebind the Grid in this stage of the application. This will call "NeedDateSource"  and you will be able to parse the columns in the format you wish.

Please refer to the following online topic  for more information on the matter.

Kind regards,
Maria Ilieva
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Mark Hubert
Top achievements
Rank 1
answered on 13 Mar 2008, 11:58 AM
Hello Maria,

I am aware of the needdatasource functionallity.
(The code was posted by Vinhlan, to which I replied).

I have a simple demo project which illustrates the issues clearly.
I don't see a way to include it in this forum however. Should I create a support ticket for you with this testproject included?  

Kind regards, 
Mark 
0
Sebastian
Telerik team
answered on 13 Mar 2008, 12:18 PM
Hi Mark,

Feel free to post the test project (attached to a formal support ticket) once you are ready with it. We will examine it carefully and will get around to you with our findings.
 
Best regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Mark Hubert
Top achievements
Rank 1
answered on 13 Mar 2008, 12:42 PM
Thank you, Stephen, see ticket 126719. 

Kind Regards,
Mark
Tags
Grid
Asked by
Vinhlan
Top achievements
Rank 1
Answers by
Mark Hubert
Top achievements
Rank 1
Maria Ilieva
Telerik team
Sebastian
Telerik team
Share this question
or