Excel Telerik

1 Answer 11 Views
ClientExportManager Grid PdfViewer XmlHttpPanel
Cristiano
Top achievements
Rank 1
Cristiano asked on 26 Jun 2025, 02:10 PM
Estou tendo um problema ao exportar meu arquivo para Excel, pois as linhas vem recolhidas, tem alguma forma de força as linhas a virem expandidas?

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 27 Jun 2025, 09:06 AM

Hi Cristiano,

To ensure that all rows, including grouped and hierarchical ones, are fully expanded when exporting to Excel from RadGrid, please apply both configuration steps below:

Step 1: RadGrid Configuration (Before Export)

Ensure your RadGrid export settings include the following:

RadGrid1.EnableGroupsExpandAll = true;
RadGrid1.EnableHierarchyExpandAll = true;

RadGrid1.ExportSettings.IgnorePaging = true;
RadGrid1.ExportSettings.ExportOnlyData = false;
RadGrid1.ExportSettings.OpenInNewWindow = true;
RadGrid1.ExportSettings.Excel.Format = GridExcelExportFormat.ExcelML;
RadGrid1.ExportSettings.Excel.DefaultCellAlignment = HorizontalAlign.Left;

RadGrid1.MasterTableView.HierarchyDefaultExpanded = true;
RadGrid1.MasterTableView.GroupsDefaultExpanded = true;

Step 2: Explicit Expansion Using ItemCreated Event

Implement explicit expansion logic by using the ItemCreated event as follows:

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem item)
    {
        item.Expanded = true;

        foreach (GridTableView nestedView in item.ChildItem.NestedTableViews)
        {
            if (nestedView.Items.Count > 0)
            {
                foreach (GridDataItem childItem in nestedView.Items)
                {
                    childItem.Expanded = true;
                }
            }
        }
    }
}
Make sure you hook this event correctly in your markup:
<telerik:RadGrid ID="RadGrid1" runat="server" OnItemCreated="RadGrid1_ItemCreated">

Final Step: Exporting to Excel

After applying the above configurations, trigger the export method:

RadGrid1.MasterTableView.ExportToExcel();

If the issue persists, please provide the following additional information to help us investigate further:

  • Your current RadGrid configuration (markup and code-behind).
  • The hierarchy loading mode (HierarchyLoadMode) configured in your RadGrid.
  • A screenshot of the RadGrid and what you'd like to export.

 

    Regards,
    Rumen
    Progress Telerik

    Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources
    Tags
    ClientExportManager Grid PdfViewer XmlHttpPanel
    Asked by
    Cristiano
    Top achievements
    Rank 1
    Answers by
    Rumen
    Telerik team
    Share this question
    or