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

[Solved] telerik radgrid export to excel - How to remove default worksheet?

5 Answers 237 Views
Grid
This is a migrated thread and some comments may be shown as answers.
gafoor
Top achievements
Rank 1
gafoor asked on 07 Jul 2014, 10:12 AM
Hi All,

I have a requirement to export some data (which is completely different from radgrid's columns) into excel sheet when user clicks on radgrid's export to excel command button.   I am able to create new worksheet with required data.  How to remove default worksheet created by radgrid's columns ?

Thanks in advance
Gafoor.
9000999309

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 07 Jul 2014, 12:13 PM
Hi Gafoor,

I guess you want to hide the RadGrid and its Columns on export. Please try the following code snippet:

C#:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
  if (e.CommandName == RadGrid.ExportToExcelCommandName)
  {
    RadGrid1.Visible = false;
    foreach (GridColumn col in RadGrid1.Columns)
    {
     RadGrid1.MasterTableView.GetColumn(col.UniqueName).Visible = false;
    }       
  }
}

Thanks,
Shinu
0
gafoor
Top achievements
Rank 1
answered on 08 Jul 2014, 06:04 AM
Hi Shinu,

Thank you very much for your response.

I already did the change you suggested to hide grid data in excel worksheet and grid data was not displaying in excel sheet.  But the default worksheet remains exist in excel file.  I want to remove/hide default worksheet as well. Please check attachment which contains excel screenshot. 

Thank you again,
Gafoor.
0
Accepted
Kostadin
Telerik team
answered on 10 Jul 2014, 02:37 PM
Hello Gafoor,

Could you please let me know which export format you are using? Basically a possible solution is to use the ExportInfrastructure and manually generate the export file. Please check out the following help article which elaborates more on this matter. Additionally you could examine the following code library as well.

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
gafoor
Top achievements
Rank 1
answered on 11 Jul 2014, 09:24 AM
Thank you Kostadin,

I referred the links which you provided to export data to excel.

Thanks again,
Gafoor.
0
gafoor
Top achievements
Rank 1
answered on 11 Jul 2014, 09:27 AM
Hello Kostadin & Shinu,

Thanks for your support.

Regards
Gafoor.
Tags
Grid
Asked by
gafoor
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
gafoor
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or