RadGrid export issues

8 posts, 0 answers
  1. Creative Memories IT Group
    Creative Memories IT Group avatar
    2 posts
    Member since:
    Sep 2008

    Posted 20 Jan 2010 Link to this post

    I am having issues exporting the RadGrid.  I have a grid with multiple pages and multiple detail tables.  I would like to export all pages, but no detail tables.  I have found that if ExportSettings.IgnorePaging  = true, then I get all pages with every single detail table.  If I set 

    ExportSettings.IgnorePaging = false, then I don't get any detail tables, but I also only get the page of the grid that I am currently on.  Is there a way to get all pages, but not the detail tables? 

    I have played with the MasterTableView.HierarchyDefaultExpanded property, but I have found that it does nothing at all for me so it does not matter what I set it to.

     

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 21 Jan 2010 Link to this post

    Hello,

    Try disabling the paging temporarily using the AllowPaging property of the MasterTableView while exporting as shown below and see if it helps:
    c#:
    protected void Button1_Click(object sender, EventArgs e)  
        {  
            RadGrid1.ExportSettings.OpenInNewWindow = true;  
            RadGrid1.MasterTableView.AllowPaging = false;  
            RadGrid1.MasterTableView.HierarchyDefaultExpanded = false;  
            RadGrid1.MasterTableView.Rebind();  
            RadGrid1.MasterTableView.ExportToExcel();  
        }  
     

    Hope this helps..
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Creative Memories IT Group
    Creative Memories IT Group avatar
    2 posts
    Member since:
    Sep 2008

    Posted 21 Jan 2010 Link to this post

    Thanks for the reply.  I do have the allowPaging property set to false.  Here is the code that I have now.
                 
    MasterTableView.AllowPaging = false;  
    MasterTableView.HierarchyDefaultExpanded = false;           
    ExportSettings.ExportOnlyData = true;  
    ExportSettings.IgnorePaging = true;  //true - exports detail tables. false - does not  
    ExportSettings.OpenInNewWindow = true;    
    foreach (GridTableView lDetailGrid in base.MasterTableView.DetailTables)  
    {  
       lDetailGrid.HierarchyDefaultExpanded = false;  
    }  
    MasterTableView.ExportToExcel(); 
    I am still getting detail grids in the export.  I had forgotten about the foreach loop that I had.  Originally I had set each detail grid's HierarchyDefaultExpanded property to true.  I changed this to false and now I don't get the second level detail grid in the export, but I still get the first level detail grid for every row.

    I also don't rebind that grid on export as it was doubling my footer totals.  I did try the rebind again, but it didn't change the outcome.

    Any other ideas would be appreciated.  Thanks!
  5. Daniel
    Admin
    Daniel avatar
    4943 posts

    Posted 22 Jan 2010 Link to this post

    Hello,

    I'm not sure that I understand what causes this behavior - could you please attach (in support ticket) a runnable project that demonstrate the problem?

    In the meantime you could try this approach:
    protected void RadGrid1_ExcelExportCellFormatting(object source, ExcelExportCellFormattingEventArgs e)
    {
        GridItem item = e.Cell.Parent as GridItem;
        if (item.OwnerTableView.Name != "MyMasterTableView")
            item.OwnerTableView.Visible = false;
    }

    <MasterTableView Name="MyMasterTableView"....

    Best regards,
    Daniel
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Byland
    Byland avatar
    5 posts
    Member since:
    Dec 2009

    Posted 31 Jan 2010 Link to this post

    In the page aspx, I add OnExcelMLExportStylesCreated="RadGrid1_ExcelMLExportStylesCreated" , OnExcelExportCellFormatting="RadGrid1_ExcelExportCellFormatting" ,   in the back page the code is below:

    protected void RadGrid1_ExcelMLExportStylesCreated(object source, Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLStyleCreatedArgs e)
            {
                foreach (Telerik.Web.UI.GridExcelBuilder.StyleElement style in e.Styles)
                {
                    style.Attributes["BorderColor"] = "black";
                    if (style.Id == "headerStyle")
                    {
                        style.FontStyle.Bold = true;
                        style.FontStyle.Color = System.Drawing.Color.Black;
                        style.InteriorStyle.Color = System.Drawing.Color.Wheat;
                        style.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid;
                    }
                    else if (style.Id == "itemStyle")
                    {
                        style.InteriorStyle.Color = System.Drawing.Color.WhiteSmoke;
                        style.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid;
                    }
                    else if (style.Id == "alternatingItemStyle")
                    {
                        style.InteriorStyle.Color = System.Drawing.Color.LightGray;
                        style.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid;
                    }
                }
                Telerik.Web.UI.GridExcelBuilder.StyleElement myStyle = new Telerik.Web.UI.GridExcelBuilder.StyleElement("MyCustomStyle");
                myStyle.FontStyle.Bold = true;
                myStyle.FontStyle.Italic = true;
                myStyle.InteriorStyle.Color = System.Drawing.Color.Gray;
                myStyle.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid;
                e.Styles.Add(myStyle);
              

            }



           protected void RadGrid1_ExcelExportCellFormatting(object source, Telerik.Web.UI.ExcelExportCellFormattingEventArgs e)
            {

                e.Cell.Style["BorderColor"] = "black";
                if (e.FormattedColumn.UniqueName == "EacReportDate")
                {
                    e.Cell.Style["mso-number-format"] = @"d\-mmm\-yyyy";
                }
                if (e.FormattedColumn.UniqueName == "WarrantyEndDate")
                {
                    e.Cell.Style["mso-number-format"] = @"d\-mmm\-yyyy";
                }
                if (e.FormattedColumn.UniqueName == "WarrantyStartDate")
                {
                    e.Cell.Style["mso-number-format"] = @"d\-mmm\-yyyy";
                }
            }

    but only run protected void RadGrid1_ExcelMLExportStylesCreated, Why????

  7. Daniel
    Admin
    Daniel avatar
    4943 posts

    Posted 02 Feb 2010 Link to this post

    Hello Zhang,

    ExcelExportCellFormatting event fires only when using the HTML Excel format - this is why it won't fire in your scenario.
    Word/Excel export (HTML-based)

    For ExcelML you could use ExcelMLExportStylesCreated and ExcelMLRowCreated.
    ExcelML export

    Regards,
    Daniel
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  8. David
    David avatar
    1 posts
    Member since:
    Jul 2014

    Posted 11 May 2015 Link to this post

    I want to keep the zeros on the left of my numerical data, anyone knows what i need to do? 
  9. Daniel
    Admin
    Daniel avatar
    4943 posts

    Posted 12 May 2015 Link to this post

    Hello David,

    Could you please let me know which Excel export format is used in your scenario (HTML, ExcelML, Biff, Xlsx)? This will help me provide straight to the point example.

    Regards,
    Daniel
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

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