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

RadGrid export issues

7 Answers 203 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Creative Memories IT Group
Top achievements
Rank 1
Creative Memories IT Group asked on 20 Jan 2010, 08:47 PM
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.

 

7 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 21 Jan 2010, 08:41 AM
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.
0
Creative Memories IT Group
Top achievements
Rank 1
answered on 21 Jan 2010, 03:28 PM
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!
0
Daniel
Telerik team
answered on 22 Jan 2010, 07:45 PM
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.
0
Byland
Top achievements
Rank 1
answered on 01 Feb 2010, 02:47 AM
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????

0
Daniel
Telerik team
answered on 02 Feb 2010, 09:59 PM
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.
0
David
Top achievements
Rank 1
answered on 11 May 2015, 09:57 PM
I want to keep the zeros on the left of my numerical data, anyone knows what i need to do? 
0
Daniel
Telerik team
answered on 12 May 2015, 11:52 AM
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.

 
Tags
Grid
Asked by
Creative Memories IT Group
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Creative Memories IT Group
Top achievements
Rank 1
Daniel
Telerik team
Byland
Top achievements
Rank 1
David
Top achievements
Rank 1
Share this question
or