RadGrid Export Excel extra line

16 posts, 0 answers
  1. Alan
    Alan avatar
    6 posts
    Member since:
    Apr 2008

    Posted 01 Dec 2008 Link to this post

    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
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 Dec 2008 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Alan
    Alan avatar
    6 posts
    Member since:
    Apr 2008

    Posted 02 Dec 2008 Link to this post

    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 
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 02 Dec 2008 Link to this post

    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.
  6. Jafin
    Jafin avatar
    86 posts
    Member since:
    Nov 2005

    Posted 03 Feb 2009 Link to this post

    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?

  7. Andrea
    Andrea avatar
    64 posts
    Member since:
    Jan 2005

    Posted 03 Feb 2009 Link to this post

    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.
  8. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 03 Feb 2009 Link to this post

    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.
  9. Andrea
    Andrea avatar
    64 posts
    Member since:
    Jan 2005

    Posted 03 Feb 2009 Link to this post

    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.



  10. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 03 Feb 2009 Link to this post

    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.
  11. Andrea
    Andrea avatar
    64 posts
    Member since:
    Jan 2005

    Posted 06 Feb 2009 Link to this post

    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!
  12. Laurie
    Laurie avatar
    141 posts
    Member since:
    Feb 2007

    Posted 17 Feb 2010 Link to this post

    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
  13. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 17 Feb 2010 Link to this post

    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.
  14. Laurie
    Laurie avatar
    141 posts
    Member since:
    Feb 2007

    Posted 17 Feb 2010 Link to this post

    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.
  15. Laurie
    Laurie avatar
    141 posts
    Member since:
    Feb 2007

    Posted 18 Feb 2010 Link to this post

    Correction:  it works just fine.  Sorry for any confusion.

    Thanks.

    Laurie
  16. Andres
    Andres avatar
    1 posts
    Member since:
    Jun 2014

    Posted 23 Oct 2014 Link to this post

    It works for me, thanks
  17. Warrick
    Warrick avatar
    7 posts
    Member since:
    Oct 2007

    Posted 18 Jan 2015 Link to this post

    I could not get it to work 100% until I followed the "Laurie-demo.zip" from Daniel

    Thanks so much
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017