Export to excel for more than 30k records is not working

1 Answer 26 Views
Grid
Sajid
Top achievements
Rank 1
Iron
Sajid asked on 18 Feb 2025, 12:09 PM | edited on 19 Feb 2025, 01:24 PM

I am not able to download more than 30k records into excel. Sometimes i am getting 500 error some time not but excel is not downloaded any time.

This is my code

 

@(Html.ReportsGrid
<apexportal.WebService.Models.AuditReportResult>()
    .HtmlAttributes(new { @style = "height: 500px;" })
    .Name("AuditReportGrid")
    .Excel(e => { e.FileName("AuditReport.xlsx").AllPages(true); })
    .Events(e => { e.ExcelExport("excelExportCheck"); })
    .AutoBind(false)
    .DataSource(datasource => datasource
    .Custom()
    .Type("aspnetmvc-ajax")
    .Transport(t => t.Read(r => r.Action("Read", "AuditReport").Data("getAdditionalData")))
    .Schema(s => s
    .Data("Data")
    .Model(model =>
    {
    model.Id(itm => itm.VR_Audit_LogID); //("VR_Audit_LogID");
    model.Field("VendorID", typeof(string));
    model.Field("ActionTime", typeof(DateTime));
    model.Field("ReviewedDate", typeof(DateTime));
    })
    .Total("Total")
    )
    .ServerSorting(true)
    .ServerPaging(true)
    .ServerFiltering(true)
    .ServerGrouping(false)
    .ServerAggregates(false)
    .Events(events => events.Error("error_handler"))
    )
    .Columns(columns =>
    {
    columns.Bound(portal => portal.VR_ID).Title("VR ID".Translate())
    .HeaderHtmlAttributes(new { @class = "NumericHeaderAlign" }).HtmlAttributes(new { @class = "NumericRowAlign" }).Width(180)
    .Filterable(x => x.Cell(y => y.Template("NumericFilter")));
    if (userACL.IsRegistrationEnabled &&!userACL.IsCustomerRegistrationEnabled)
    {
    columns.Bound(portal => portal.VendorID).Title("Vendor ID".Translate())
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(150);
    }
    if (userACL.IsCustomerRegistrationEnabled)
    {
    columns.Bound(portal => portal.VendorID).Title("Entity ID".Translate())
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(150);
    }
    columns.Bound(portal => portal.CompanyName).Title("Company Name".Translate())
    .ClientTemplate("#=buildCompanyNameLink(CompanyName, '" + @Url.Action("GetCompanyUrl") + "')#")
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(200);
    columns.Bound(portal => portal.ModifiedFieldName).Title("Field Name".Translate())
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(250);
    columns.Bound(portal => portal.DecryptedOriginalValue).Title("Original Value".Translate())
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(150);
    columns.Bound(portal => portal.DecryptedNewValue).Title("New Value".Translate())
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(150);
    columns.Bound(portal => portal.ChangedBy).Title("Changed By".Translate())
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(150);
    columns.Bound(portal => portal.ChangedByFirstName).Title("Changed By First Name".Translate())
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(150);
    columns.Bound(portal => portal.ChangedByLastName).Title("Changed By Last Name".Translate())
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(150);
    columns.Bound(portal => portal.RegistrationType).ClientTemplate("#= RegistrationType == null ? '' : TranslateText(RegistrationType) #").Title("Registration Type".Translate())
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(150);
    if (userACL.IsCustomerRegistrationEnabled && userACL.IsRegistrationEnabled)
    {
    columns.Bound(portal => portal.ProfileType).ClientTemplate("#= ProfileType == null ? '' : TranslateText(ProfileType) #").Title("Profile Type".Translate())
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(150);
    }
    columns.Bound(portal => portal.Action).ClientTemplate("#= Action == null ? '' : TranslateText(Action) #").Title("Action".Translate())
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(110);
    //columns.Bound(portal => portal.PRIMARY_KEY).Title("Primary Key".Translate()).HtmlAttributes(new { @style = "white-space: nowrap;" }).Width(110);
    columns.Bound(portal => portal.DataSource).Title("Data Source".Translate())
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(110);
    columns.Bound(portal => portal.ActionTime).Title("Action Time".Translate()).Format("{0:G}")
    .HeaderHtmlAttributes(new { @class = "DateHeaderAlign" }).HtmlAttributes(new { @class = "DateRowAlign" }).Width(150);
    columns.Bound(portal => portal.ReviewMode).ClientTemplate("#= ReviewMode == null ? '' : TranslateText(ReviewMode) #").Title("Review Action".Translate())
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(110);
    columns.Bound(portal => portal.ReviewedBy).Title("Reviewed By".Translate())
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(110);
    columns.Bound(portal => portal.ReviewedDate).Title("Reviewed Date".Translate()).Format("{0:G}")
    .HeaderHtmlAttributes(new { @class = "DateHeaderAlign" }).HtmlAttributes(new { @class = "DateRowAlign" }).Width(150);
    }
    )
    .Filterable(filterable => filterable
    .Extra(false)
    .Operators(operators => operators
    .ForDate(str => str.Clear()
    .IsNotEqualTo("Is not equal to".Translate())
    .IsGreaterThanOrEqualTo("Is after or equal to".Translate())
    .IsGreaterThan("Is after".Translate())
    .IsLessThanOrEqualTo("Is before or equal to".Translate())
    .IsLessThan("Is before".Translate())
    .IsNull("Is Null".Translate())
    .IsNotNull("Is Not Null".Translate()))))
    )
    }

 

    @Html.GridErrorHandler()
    @Html.GridResizeHandler("AuditReportGrid")
    @CustomHtml.GridContextMenu(Html, "AuditReportGrid")
    @CustomHtml.EnableFormValidation("SearchForm", "searchbtn")

1 Answer, 1 is accepted

Sort by
0
Anton Mironov
Telerik team
answered on 21 Feb 2025, 07:58 AM

Hello Sajid,

Thank you for the code snippet and the details provided.

In order to export a large collection of data from the Grid, I would recommend using the server export. Here is a demo:

The following article provides additional information about the implementation process of the server export:

 

Kind Regards,
Anton Mironov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Grid
Asked by
Sajid
Top achievements
Rank 1
Iron
Answers by
Anton Mironov
Telerik team
Share this question
or