Export RadGrid (Docx)

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

    Posted 10 Jun Link to this post

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

    RadGrid1.ExportSettings.Word.Format = Telerik.Web.UI.GridWordExportFormat.Docx;
    RadGrid1.ExportSettings.UseItemStyles = true;

    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
    Kostadin avatar
    1693 posts

    Posted 15 Jun Link to this post


    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.

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