【问题标题】:Telerik Kendo grid-export to excel is not responding when trying to export more than 4000 records to excel尝试将超过 4000 条记录导出到 excel 时,Telerik Kendo 网格导出到 excel 没有响应
【发布时间】:2016-02-02 17:48:59
【问题描述】:

在尝试将 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 =>

【问题讨论】:

  • 我遇到了同样的问题。但是我的网格停止从 2000 条记录中导出(但我有大约 40 列)..由于它是通过客户端导出的,我认为这将是一些内存问题......不幸的是我没有解决它......我只是从一些记录中禁用 Telerik 导出按钮。所以我投票赞成,这个问题对我来说也很有趣。

标签: excel telerik-grid


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-30
    • 2012-06-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多