radgrid excel export remove column not work!

9 posts, 0 answers
  1. JJ
    JJ avatar
    147 posts
    Member since:
    May 2010

    Posted 06 May 2011 Link to this post

    I want to remove one column and also selected rows for excel export. Remove rows worked but remove column doesn't work.

    I used e.Worksheet.Table.Columns.RemoveAt(3) under ExcelMLExportRowCreated to remove column (TagID) but doesn't work.

    I can't make the TagID column invisible on the grid display because I need to use this TagID for checking when remove selected rows. .

    -----------------------------------------------------------------------------------

     

    if (!list.Contains(e.Row.Cells.GetCellByName("TagID"

    ).Data.DataItem.ToString()))

     

    {

     


    if (e.RowType == GridExportExcelMLRowType

    .DataRow)

     


    {

     

     

     

    Int32

    i = e.Worksheet.Table.Rows.Count;

     

     

     

    e.Worksheet.Table.Rows.Remove(e.Row);  // remove rows worked

     

    }

     

    }

     

     

     

     

    else

     

     

     

    {

    e.Worksheet.Table.Columns.RemoveAt(3); // want to remove TagID column from excel display (index id is 3) but didn't work

    }


    Please help!

  2. Daniel
    Admin
    Daniel avatar
    4943 posts

    Posted 11 May 2011 Link to this post

    Hello JJ,

    You can hide the desired column by setting the Hidden property of the ColumnElement to true. Otherwise you will have to remove not only the column element but the relevant cells also.
    ExcelML structure / GridExcelBuilder

    Please use the Code snippet tool (in the toolbox above) when you paste code in the forum thread.

    Regards,
    Daniel
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. JJ
    JJ avatar
    147 posts
    Member since:
    May 2010

    Posted 13 May 2011 Link to this post

    Under which evens after ExcelMLExportRowCreated that I can use the hidden preperty. I have to remove it under or after ExcelMLExportRowCreated  is triggered. Since I still need to use this column under ExcelMLExportRowCreated.

    Thanks,
    Jessie

     

  5. Daniel
    Admin
    Daniel avatar
    4943 posts

    Posted 16 May 2011 Link to this post

    Hello Jessie,

    You have to hide the column in the ExcelMLExportRowCreated event if you use pre-Q1 2011 version. A possible approach would be to check whether the current item is the last one so that you can hide the desired columns. Dummy code:
    if(e.Worksheet.Table.Rows.Count == RadGrid1.Items.Count)
    {
        foreach(ColumnElement col in ... )
        {
            col.Hidden = true;
        }
    }

    Note that this is just an example and not a runnable code - you will have to take the header row into consideration.

    Regards,
    Daniel
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  6. JJ
    JJ avatar
    147 posts
    Member since:
    May 2010

    Posted 16 May 2011 Link to this post

    Hi Daniel

    I don't see the col (ColumnElement col) has  property "hidden"- pre-Q1 2011



  7. Daniel
    Admin
    Daniel avatar
    4943 posts

    Posted 16 May 2011 Link to this post

    Hello Jessie,

    Just add the ss:Hidden attribute to the ColumnElement object as shown below:
    colElement.Attributes.Add("ss:Hidden", "1");

    Best regards,
    Daniel
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  8. JJ
    JJ avatar
    147 posts
    Member since:
    May 2010

    Posted 16 May 2011 Link to this post

    Works cool! Thanks Daniel.

  9. Daniel
    Admin
    Daniel avatar
    4943 posts

    Posted 16 May 2011 Link to this post

    Hello Jessie,

    I'm glad that my suggestions were helpful to you. I would recommend that you bookmark the link below, it points to Microsoft's XMLSS documentation:
    XML Spreadsheet Reference

    Best regards,
    Daniel
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  10. JJ
    JJ avatar
    147 posts
    Member since:
    May 2010

    Posted 16 May 2011 Link to this post

    Thanks Daniel. This is helpful.

    Jessie
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017