gpt4 book ai didi

excel - 尝试将超过 4000 条记录导出到 excel 时,Telerik Kendo 网格导出到 excel 没有响应

转载 作者:行者123 更新时间:2023-12-04 21:01:39 25 4
gpt4 key购买 nike

尝试将超过 4000 条记录导出到 excel 时,Kendo 网格导出到 excel 没有响应……而且它甚至没有抛出错误消息……有人可以建议或建议解决这个问题。

这是剑道网格的代码

                            @(Html.Kendo().Grid(Model)
.Name("Billinggrid")

.Columns(columns =>
{
columns.Bound(c => c.groupid).Width(75).Filterable(true).Sortable(true).HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" });
columns.Bound(c => c.groupname).Width(125).Filterable(true).Sortable(true).HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" });
columns.Bound(c => c.groupeffectivedate).Width(90).Filterable(true).Sortable(true).HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" });
columns.Bound(c => c.recipientdatareceived).Width(95).Filterable(true).Sortable(true).HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" });
columns.Bound(c => c.recipientsent).Width(100).Filterable(true).Sortable(true).HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" });
columns.Bound(c => c.accountmanager).Width(125).Filterable(true).Sortable(true).HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" });
columns.Bound(c => c.billinggroup).Width(75).Filterable(true).Sortable(true).HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" });
columns.Bound(c => c.reportyearmonth).Width(85).Filterable(true).Sortable(true).HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" });
columns.Bound(c => c.recordcount).Width(55).Filterable(false).Sortable(true).HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" });
columns.Bound(c => c.datafilecount).Width(50).Filterable(false).Sortable(true).HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" });
columns.Bound(c => c.datacharge).Format("{0:c}").Filterable(false).Sortable(false).HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" });
columns.Bound(c => c.printcharge).Format("{0:c}").Filterable(false).Sortable(false).HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" });
columns.Bound(c => c.insertcharge).Format("{0:c}").Filterable(false).Sortable(false).HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" });
columns.Bound(c => c.envelopecharge).Format("{0:c}").Filterable(false).Sortable(false).HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" });
columns.Bound(c => c.postage).Format("{0:c}").Filterable(false).Sortable(false);
columns.Bound(c => c.total).Format("{0:c}").Filterable(false).Sortable(false);
columns.Bound(c => c.postageremaining).Width(95).Format("{0:c}").Filterable(true).Sortable(true).HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" });
})

.Resizable(resizable => resizable.Columns(true))
.Reorderable(reorderable => reorderable.Columns(true))
.Pageable(pager => pager.PageSizes(new int[] { 10, 25, 50, 100, 500 })
.Messages(messages => messages.ItemsPerPage(" items displayed"))
)
.Sortable()
.Scrollable(scr => scr.Height("auto"))
.HtmlAttributes(new { style = "Font-size:x-small" })

//.ToolBar(tools => tools.Excel())
.Excel(excel => excel
.FileName("Billing_Report-" + DateTime.Now + ".xlsx")
.AllPages(true)
//.Filterable(true)
.ProxyURL(Url.Action("Excel_Export_Save", "Report"))
)
//.Filterable(ftb => ftb.Mode(GridFilterMode.Row))

.ToolBar(toolbar =>

最佳答案

来自 Telerik 论坛 System Out of Memory 的帖子

当 OpenAccess 执行查询时,实际检索的结果被分成 block 。有一个提取大小决定了一次从数据库中读取的记录数。对于返回大量记录的查询,这意味着不会超过提取大小,并且不会一次在内存中检索所有 40 000 条记录。迭代结果数据,您将从数据库中获得多次读取,直到迭代结束。但是,当您迭代结果集时,当您保留对被迭代对象的引用时,会累积后续读取。
当您对网格中的所有记录进行操作时,可能会导致内存不足异常。避免此类错误的方法是分 block 处理数据。例如,网格的分页和从所有页面顺序导出数据的选项将实现此目的。目标是尝试减少一次保存在内存中的对象,并让垃圾收集释放不需要的内存。使用 Skip() 和 Take() 的 LINQ 查询非常适合将所有数据存储在内存中的成本很高的情况。

关于excel - 尝试将超过 4000 条记录导出到 excel 时,Telerik Kendo 网格导出到 excel 没有响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35160416/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com