Export row and columns descriptors

3 posts, 1 answers
  1. IRAJA
    IRAJA avatar
    2 posts
    Member since:
    Apr 2015

    Posted 28 Apr 2015 Link to this post

    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. Answer
    Kostadin
    Admin
    Kostadin avatar
    1711 posts

    Posted 01 May 2015 Link to this post

    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. IRAJA
    IRAJA avatar
    2 posts
    Member since:
    Apr 2015

    Posted 06 May 2015 in reply to Kostadin Link to this post

    Thanks, this tip was very usefull for me.
Back to Top