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

Export row and columns descriptors

2 Answers 54 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
IRAJA
Top achievements
Rank 1
IRAJA asked on 28 Apr 2015, 09:02 PM

Hi everyone.

This week I started to use the Telerik RadPivotGrid, and today I need to export the results shown in the Pivot to the Excel.

Ok, no problems for this, but, for my business, I even have to get the row and columns descriptors in the exported File.

As in the files below, in the screen, I see the file: screen.png, but in the report; I see the file: excel.png (without the descriptors and, for some people, without sense).

There is any way to solve it?

2 Answers, 1 is accepted

Sort by
0
Accepted
Kostadin
Telerik team
answered on 01 May 2015, 11:03 AM
Hi Iraja,

I am afraid that the field names are not exported in the Excel file. Nevertheless you can manually add them by modifying the export exported document during its creation. For this purpose you have to hook OnPivotGridInfrastructureExporting event handler and add the missing information to the correct cells.
Please check out the following code snippet which demonstrates one possible solution.
protected void RadPivotGrid1_PivotGridInfrastructureExporting(object sender, PivotGridInfrastructureExportingEventArgs e)
{
    e.ExportStructure.Tables[0].ShiftRowsDown(1, 1);
 
    foreach (var field in RadPivotGrid1.Fields)
    {
        switch (field.FieldType)
        {
            case "PivotGridRowField":
                e.ExportStructure.Tables[0].Cells[1, 2].Value += field.DataField + " ";
                break;
            case "PivotGridColumnField":
                e.ExportStructure.Tables[0].Cells[2, 1].Value += field.DataField + " ";
                break;
            case "PivotGridAggregateField":
                e.ExportStructure.Tables[0].Cells[1, 1].Value += field.DataField + " ";
                break;
            default:
                break;
 
        }
    }
}


Regards,
Kostadin
Telerik
 

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

 
0
IRAJA
Top achievements
Rank 1
answered on 06 May 2015, 08:00 PM
Thanks, this tip was very usefull for me.
Tags
PivotGrid
Asked by
IRAJA
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
IRAJA
Top achievements
Rank 1
Share this question
or