This is a migrated thread and some comments may be shown as answers.
RadGrid Export Excel extra line
15 Answers 383 Views
This is a migrated thread and some comments may be shown as answers.
Alan
Top achievements
Rank 1
Alan asked on 02 Dec 2008, 04:10 AM
I am using the export to excel function for my grid, it works fine.
But there is always an extra row of empty cells between my row header and the data in the excel spreadsheet.

Does anybody know how to get rid of it ?

 

 


Cheers
Alan

15 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 02 Dec 2008, 07:14 AM
Hi Alan,

I guess you have enabled filtering in the Grid. If so try disabling it in the export button's click event.

CS:
 protected void LinkButton1_Click(object sender, EventArgs e) 
    { 
        RadGrid1.AllowFilteringByColumn = false
        RadGrid1.Rebind(); 
       
        RadGrid1.MasterTableView.ExportToExcel();  
    } 


Thanks
Shinu.
0
Alan
Top achievements
Rank 1
answered on 03 Dec 2008, 12:48 AM
Hi Shinu,

Thanks for the response.
Setting AllowFilteringByColumn to false before calling ExportToExcel got rid of the extra row
but also removes all the existing filtering I have for the grid and exports the full grid.

I don't suppose we have a way to get rid of the row and keep the filtering ??

Cheers
Alan 
0
Princy
Top achievements
Rank 1
answered on 03 Dec 2008, 05:26 AM
Hello Alan,

You can try out the following code to hide the filter row but export the filtered data.
cs:
 protected void Button_Click(object sender, EventArgs e) 
    { 
        RadGrid1.ExportSettings.OpenInNewWindow = true
        RadGrid1.ExportSettings.IgnorePaging = true
        foreach (GridFilteringItem filter in RadGrid1.MasterTableView.GetItems(GridItemType.FilteringItem)) 
        { 
            filter.Visible = false
        }   
        RadGrid1.MasterTableView.ExportToExcel(); 
   } 

Thanks
Princy.
0
Jafin
Top achievements
Rank 2
answered on 03 Feb 2009, 06:23 AM
Princy,

I tried your example verbatim and I still get <input /> tags for the filter dialog and a button in the Excel Exported content.
Any clues?

0
Andrea
Top achievements
Rank 2
answered on 03 Feb 2009, 11:42 AM
Alan said:

Setting AllowFilteringByColumn to false before calling ExportToExcel got rid of the extra row
but also removes all the existing filtering I have for the grid and exports the full grid.


This behavior is really amusing but unfortunately it's true.....

Cheers.
0
Sebastian
Telerik team
answered on 03 Feb 2009, 11:55 AM
Hello guys,

If you use the approach posted by Princy, it should merely hide the filter row in the grid (along with the controls residing inside it) to exclude it from the exported document. Only the records in the grid which are available at that time should be exported to Excel.

If you experience different behavior, please prepare a simple working demo which illustrates it and send it attached to a regular support ticket. We will test it locally and will advice you further.

Best regards,
Sebastian
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Andrea
Top achievements
Rank 2
answered on 03 Feb 2009, 12:36 PM
Perhaps the Princy approach need an extra .Rebind, with its extra cost, in some place.

You said:

."..it should merely hide....
If you experience different behavior, please prepare a simple working demo which illustrates it and send it attached to a regular support ticket. We will test it locally and will advice you further.
"

Sebastian, if you experience different behavior from us, please prepare a simple working demo of your application and post here, (without extra rebind.... :P)


Best regards.



0
Sebastian
Telerik team
answered on 03 Feb 2009, 12:41 PM
Hi Andrea,

The ExportToExcel() method of the grid forces implicit rebind which should apply changes in its structure made beforehand - am I missing something? If you observed something different, feel free to post the sample project requested before.

Regards,
Sebastian
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Andrea
Top achievements
Rank 2
answered on 06 Feb 2009, 03:07 PM
I know this, I mean extra "Export included" Rebinds .

I partially solved with ExcelML format.

It's very simple to reproduce the problem for you (see this thread) and, sincerely, I dont have time to act as beta tester.

Good Work!
0
Laurie
Top achievements
Rank 2
answered on 17 Feb 2010, 07:57 PM
Have you folks at Telerik come up with a solution for this yet?  I'm having the same issue.  If I turn AllowFIlteringByColumn off, I get all the records I'd filtered out.  If I leave out the Allowfilterinbycolumn line and use the filter.Visible = false code above, the excel and word files look the same as if I do not include that code.  Please help.

Thanks.

Laurie
0
Daniel
Telerik team
answered on 17 Feb 2010, 08:28 PM
Hello Laurie,

Please download the sample project that I created for you and let me know whether it behaves as you expect on your end.

Regards,
Daniel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Laurie
Top achievements
Rank 2
answered on 17 Feb 2010, 08:55 PM
Yes it does.  And when I bind my data to the grid it works as well.  In attempting to apply the logic to my application, however, it works when I export to word but not when I export to excel.  The main differences between your grid and mine are that you're auto generating columns and I'm not and I am using FilterTemplate in my grid.
0
Laurie
Top achievements
Rank 2
answered on 18 Feb 2010, 05:25 PM
Correction:  it works just fine.  Sorry for any confusion.

Thanks.

Laurie
0
Andres
Top achievements
Rank 1
answered on 23 Oct 2014, 02:58 PM
It works for me, thanks
0
Warrick
Top achievements
Rank 1
answered on 18 Jan 2015, 01:26 PM
I could not get it to work 100% until I followed the "Laurie-demo.zip" from Daniel

Thanks so much
Tags
Grid
Asked by
Alan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Alan
Top achievements
Rank 1
Princy
Top achievements
Rank 1
Jafin
Top achievements
Rank 2
Andrea
Top achievements
Rank 2
Sebastian
Telerik team
Laurie
Top achievements
Rank 2
Daniel
Telerik team
Andres
Top achievements
Rank 1
Warrick
Top achievements
Rank 1
Share this question
or