Since the grid export has performed through tabular method it took ~4min to export. Hence we have tested the grid data export using the “XlsIO - Improving performance and memory while importing data” feature of the XlslO and it took nearly 15sec to export 1k records and tested your sample using the below code snippet. So we suggest you to use the below code example to reduce the time for Export the Grid data.
Refer to the modified sample in following link: Sample
protected void gridDataReport2_ServerExcelExporting(object sender, Syncfusion.JavaScript.Web.GridEventArgs e) { var db = new Model1(); var datos = db.InformeDiarioGasDetalles.ToList<InformeDiarioGasDetalles>(); ExcelExport exp = new ExcelExport();
ExcelEngine excelEngine = new ExcelEngine(); IApplication application = excelEngine.Excel; IWorkbook workbook = application.Workbooks.Create();
workbook.Worksheets[0].ImportData((IEnumerable)datos, 1, 1, true); workbook.Version = ExcelVersion.Excel2013;
workbook.SaveAs("Export.xlsx", HttpContext.Current.Response, ExcelDownloadType.PromptDialog, ExcelHttpContentType.Excel2010);
} |
Please refer the below link for more details on using the above improved performance exporting.
http://help.syncfusion.com/file-formats/xlsio/improving-performance#importing-datatable
The limitation on using the above technique.
1. Styles cannot be applied
Regards,
Balaji Marimuthu
We have considered the requirement “Improve performance of Grid Excel Export when Grouping with large data” as a feature and a support incident has been created under your account to track the status of this requirement. Please log on to our support website to check for further updates.
https://www.syncfusion.com/account/login?ReturnUrl=/support/directtrac/incidents
Query:2 Styling with large Data
If apply styling for large data then need to process all the cells to apply style while exporting and it will reduce the performance of Exporting. So we suggest you to use the XLSIO style properties and apply the style property to differentiate the Header cell. Refer to the Sample, code example, and help document as follows,
Sample: WebApplication1
Help Document: http://help.syncfusion.com/file-formats/xlsio/working-with-cell-or-range-formatting#apply-global-style
protected void gridDataReport2_ServerExcelExporting(object sender, Syncfusion.JavaScript.Web.GridEventArgs e) { var db = new Model1(); var datos = db.InformeDiarioGasDetalles.ToList<InformeDiarioGasDetalles>(); ExcelExport exp = new ExcelExport();
ExcelEngine excelEngine = new ExcelEngine(); IApplication application = excelEngine.Excel; IWorkbook workbook = application.Workbooks.Create(); IWorksheet worksheet = workbook.Worksheets[0]; //IListObject table = worksheet.ListObjects.Create("Table1", worksheet ["A1:C8"]);
//// Formatting table with a built-in style
//table.BuiltInTableStyle = TableBuiltInStyles.TableStyleMedium9;
workbook.SetPaletteColor(8, Color.FromArgb(255, 174, 33));
//Defining header style
IStyle headerStyle = workbook.Styles.Add("HeaderStyle");
headerStyle.BeginUpdate();
headerStyle.Color = Color.FromArgb(255, 174, 33);
headerStyle.Font.Bold = true;
headerStyle.Borders[ExcelBordersIndex.EdgeLeft].LineStyle = ExcelLineStyle.Thin;
headerStyle.Borders[ExcelBordersIndex.EdgeRight].LineStyle = ExcelLineStyle.Thin;
headerStyle.Borders[ExcelBordersIndex.EdgeTop].LineStyle = ExcelLineStyle.Thin;
headerStyle.Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin;
headerStyle.EndUpdate();
//Add custom colors to the palette.
workbook.SetPaletteColor(9, Color.FromArgb(239, 243, 247));
workbook.Worksheets[0].ImportData((IEnumerable)datos, 1, 1, true); workbook.Version = ExcelVersion.Excel2013;
//Apply Header style.
worksheet.Rows[0].CellStyle = headerStyle;
//Auto-fit the columns
worksheet.UsedRange.AutofitColumns(); workbook.SaveAs("Export.xlsx", HttpContext.Current.Response, ExcelDownloadType.PromptDialog, ExcelHttpContentType.Excel2010);
//exp.Export(gridDataReport2.Model, (IEnumerable)datos, "Details.xlsx", ExcelVersion.Excel2010, true, true, "none"); |