We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Grid Export Formatting

Thread ID:





123892 Apr 29,2016 10:47 AM UTC May 2,2016 11:54 AM UTC ASP.NET MVC 1
Tags: Grid
Asked On April 29, 2016 10:47 AM UTC

Hi there,
Is it possible to format export (excel or pdf) by changing the background colour, header background colour font, adding group header etc?
I have a requirement to group the list by certain column (also providing group header )

Balaji Marimuthu [Syncfusion]
Replied On May 2, 2016 11:54 AM UTC

Hi Prasanthan, 
Thanks for contacting Syncfusion support. 
To customize the Grid we suggest you to use the AutoFormat Class. The AutoFormat Class can be used to customize the styles or themes applied to the exported grid. With the autoFormat class, you can provide required color to the grid content, alt row background or border color. 
private GridProperties ConvertGridObject(string gridProperty) 
            JavaScriptSerializer serializer = new JavaScriptSerializer(); 
            IEnumerable div = (IEnumerable)serializer.Deserialize(gridProperty, typeof(IEnumerable)); 
            GridProperties gridProp = new GridProperties(); 
            foreach (KeyValuePair<string, object> ds in div) 
                var property = gridProp.GetType().GetProperty(ds.Key, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase); 
                if (property != null) 
                    Type type = property.PropertyType; 
                    string serialize = serializer.Serialize(ds.Value); 
                    object value = serializer.Deserialize(serialize, type); 
                    property.SetValue(gridProp, value, null); 
            AutoFormat auto = new AutoFormat(); 
            auto.FontFamily = "Arial"; 
            auto.ContentBorderColor = Color.Brown; 
            auto.ContentFontSize = 10; 
            auto.GCaptionBorderColor = Color.Cornsilk; 
            auto.GContentFontColor = Color.DarkBlue; 
            auto.HeaderFontSize = 12; 
            auto.HeaderBorderColor = Color.Red; 
            auto.ContentBgColor = Color.Wheat; 
            auto.GHeaderBgColor = Color.Crimson; 
            auto.AltRowBgColor = Color.LightCyan; 
            gridProp.AutoFormat = auto; 
            return gridProp; 
public void ExportToExcel(string GridModel) 
            ExcelExport exp = new ExcelExport(); 
            var DataSource = new NorthwindDataContext().OrdersViews.Take(30).ToList(); 
            GridProperties obj = ConvertGridObject(GridModel); 
            exp.Export(obj, DataSource, "Export.xlsx", ExcelVersion.Excel2010, false, false, "none"); 
Refer to the Sample and help document in following link. 
Sample: Sample-123892 
Balaji Marimuthu 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon