This is a migrated thread and some comments may be shown as answers.
Radgrid Export to Excel Column width
2 Answers 69 Views
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 08 Aug 2018, 04:57 PM

Hi,

We need to set the column width in export to excel file. Currently, its fit the width by using its Header Text. We need to customize it like in grid we have 50px column width but when we export to excel we want to set 20px. How can we achieve the goal? Any sample application would be appreciated.

2 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 13 Aug 2018, 08:17 AM
Hello Eric,

Supposing that you are using the following Excel export format:
<ExportSettings>
    <Excel Format="Xlsx" />
</ExportSettings>

You can use the following approach to achieve this requirement:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    if (RadGrid1.IsExporting)
    {
        foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns)
        {
            if (col.UniqueName == "ShipCountry")
            {
                col.HeaderStyle.Width = 500;
                break;
            }
        }
    }
}

I hope this will prove helpful.

Regards,
Eyup
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Sharamae
Top achievements
Rank 1
answered on 13 Aug 2018, 12:38 PM
Hi Eric! Try using the Zetexcel. It's a very powerful tool for this. You may google it.
Tags
Grid
Asked by
Eric
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Sharamae
Top achievements
Rank 1
Share this question
or