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

Export RadGrid (Docx)

1 Answer 124 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Developer
Top achievements
Rank 1
Developer asked on 10 Jun 2016, 02:31 PM

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?

1 Answer, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 15 Jun 2016, 08:24 AM
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.
Tags
Grid
Asked by
Developer
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Share this question
or