Export RadGrid (Docx)

2 posts, 0 answers
  1. Developer
    Developer avatar
    38 posts
    Member since:
    Apr 2014

    Posted 10 Jun Link to this post

    Hi,
    I’m trying to export a radgrid using this code:

    RadGrid1.ExportSettings.Word.Format = Telerik.Web.UI.GridWordExportFormat.Docx;
    RadGrid1.ExportSettings.UseItemStyles = true;
    RadGrid1.MasterTableView.ExportToWord();


    This works but I’m trying to do the following unsuccessfully

    1. Make the word file landscape mode
    2. Add a header and footer

    Please can you clarify how to accomplish these things please?

  2. Kostadin
    Admin
    Kostadin avatar
    1713 posts

    Posted 15 Jun Link to this post

    Hi,

    Generally you can add header and footer by hooking OnInfrastructureExporting event handler and add rows at the beginning and at the end of the ExportInfrastructure Table. Please check out the following code snippet.
    protected void RadGrid1_InfrastructureExporting(object sender, Telerik.Web.UI.GridInfrastructureExportingEventArgs e)
    {
        xls.Table table = e.ExportStructure.Tables[0];
        table.ShiftRowsDown(1, 1);
        table.Cells[1, 1].Colspan = 4;
        table.Cells[1, 1].Value = "Header Text";
        table.Cells[1, table.Rows.Count + 2].Colspan = 4;
        table.Cells[1, table.Rows.Count + 2].Value = "Footer Text";
    }

    Regards changing the page orientation to landscape I am afraid this is not supported.

    Regards,
    Kostadin
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top