Articles in this section
Category / Section

What may be done to enhance Excel exporting performance in ASP.NET Web Forms Grid?

3 mins read

Grid Excel Exporting will slow down while the record count is more. This is because the cells excel will be set to fit based on content given to them. Setting the theme to the excel file also slow down the Excel generation.

 

Solution:

To improve the performance of the Excel file Exporting, disable the IsAutoFit, IsAutoFitRows and set Theme to ‘none’.

 

MVC or .Net core Controller:

 
    public class HomeController : Controller
    { 
        public void ExportToExcel(string GridModel)
        {
            ExcelExport exp = new ExcelExport();
            var DataSource = OrderRepository.GetAllRecords();
            GridProperties obj = ConvertGridObject(GridModel); 
 
            //define other properties using GridExcelExport 
            GridExcelExport gridExport = new GridExcelExport();
            gridExport.FileName = "Export.xlsx";
            gridExport.Excelversion = ExcelVersion.Excel2010;
 
            /*Disable the Theme; IsAutoFit; IsAutoFitRows*/
            gridExport.Theme = "none";
            gridExport.IsAutoFit = false;
            gridExport.IsAutoFitRows = false;
            /*End of Solution*/
 
            exp.Export(obj, DataSource, gridExport);
        }
        private GridProperties ConvertGridObject(string gridProperty)
        {
            GridProperties gridProp = new GridProperties();
            gridProp = (GridProperties)JsonConvert.DeserializeObject(gridProperty, typeof(GridProperties));
            return gridProp;
        }
    }

 

Asp.Net WebForms Code Behind:

    public partial class _Default : Page
    {
        protected void FlatGrid_ServerExcelExporting(object sender, Syncfusion.JavaScript.Web.GridEventArgs e)
        {
            ExcelExport exp = new ExcelExport();
            
            //define other properties using GridExcelExport
            GridExcelExport gridExport = new GridExcelExport();
 
            gridExport.FileName = "Export.xlsx";
            gridExport.Excelversion = ExcelVersion.Excel2010;
 
            /*Disable the Theme; IsAutoFit; IsAutoFitRows*/
            gridExport.Theme = "none";
            gridExport.IsAutoFit = false;
            gridExport.IsAutoFitRows = false;
            /*End of Solution*/
 
            exp.Export(FlatGrid.Model, (IEnumerable)FlatGrid.DataSource, gridExport);
        }
    }

 

Note:

A new version of Essential Studio for ASP.NET is available. Versions prior to the release of Essential Studio 2014, Volume 2 will now be referred to as a classic versions.The new ASP.NET suite is powered by Essential Studio for JavaScript providing client-side rendering of HTML 5-JavaScript controls, offering better performance, and better support for touch interactivity. The new version includes all the features of the old version, so migration is easy.

The Classic controls can be used in existing projects; however, if you are starting a new project, we recommend using the latest version of Essential Studio for ASP.NET. Although Syncfusion will continue to support all Classic Versions, we are happy to assist you in migrating to the newest edition.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls. If you have any queries or require clarifications, please let us know in the comments section below.

You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied