Export Header Areas | RadPivotGrid for ASP.NET AJAX Documentation
Edit this page

Export Header Areas

The example below demonstrates how to add the Data, Row and Column header areas in the Excel document. The solution is to add a new row at the beginning of the document and populate it with the appropriate field names. You can access the spreadsheet on PivotGridInfrastructureExporting event handler and use ShiftRowsDown to insert a row at the beginning of the document.

protected void RadPivotGrid1_PivotGridInfrastructureExporting(object sender, PivotGridInfrastructureExportingEventArgs e)
    e.ExportStructure.Tables[0].ShiftRowsDown(1, 1);

    foreach (var field in RadPivotGrid1.Fields)
        if (!field.IsHidden)
            switch (field.FieldType)
                case "PivotGridRowField":
                    e.ExportStructure.Tables[0].Cells[1, 2].Value += field.DataField + " ";
                case "PivotGridColumnField":
                    e.ExportStructure.Tables[0].Cells[2, 1].Value += field.DataField + " ";
                case "PivotGridAggregateField":
                    e.ExportStructure.Tables[0].Cells[1, 1].Value += field.DataField + " ";

Protected Sub RadPivotGrid1_PivotGridInfrastructureExporting(sender As Object, e As PivotGridInfrastructureExportingEventArgs)
    e.ExportStructure.Tables(0).ShiftRowsDown(1, 1)

    For Each field As var In RadPivotGrid1.Fields
        If Not field.IsHidden Then
            Select Case field.FieldType
                Case "PivotGridRowField"
                    e.ExportStructure.Tables(0).Cells(1, 2).Value += field.DataField + " "
                    Exit Select
                Case "PivotGridColumnField"
                    e.ExportStructure.Tables(0).Cells(2, 1).Value += field.DataField + " "
                    Exit Select
                Case "PivotGridAggregateField"
                    e.ExportStructure.Tables(0).Cells(1, 1).Value += field.DataField + " "
                    Exit Select
                Case Else
                    Exit Select

            End Select
        End If
End Sub
Is this article helpful? No Yes
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article