Radgrid Export to Excel Column width

3 posts, 0 answers
  1. Eric
    Eric avatar
    12 posts
    Member since:
    Aug 2010

    Posted 08 Aug 2018 Link to this post

    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. Eyup
    Admin
    Eyup avatar
    3647 posts

    Posted 13 Aug 2018 Link to this post

    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.
  3. Sharamae
    Sharamae avatar
    1 posts
    Member since:
    Aug 2018

    Posted 13 Aug 2018 in reply to Eric Link to this post

    Hi Eric! Try using the Zetexcel. It's a very powerful tool for this. You may google it.
Back to Top