【问题标题】:Fast Export to Excel using transpose使用转置快速导出到 Excel
【发布时间】:2018-11-13 17:48:42
【问题描述】:

我使用了此链接中发布的解决方案 Fast Export of Large Datatable to Excel Spreadsheet in VB.Net

并且工作得很好,但是当我的代码导出超过 15513 行时,代码失败并且仅在列上显示“#N/A”。如下图所示

Error on export a big number of lines 查看使用的代码:

        'numero de linhas
        Dim Nbligne As Long = dt.Rows.Count

        'Grava o cabeçalho das colunas e os dados
        For Each dc In dt.Columns

            colIndex = colIndex + 1
            'Cabeçalhos
            oWsh.Cells(1, colIndex) = dc.ColumnName
            oWsh.Cells(2, colIndex).Resize(Nbligne, ).Value = oXls.Application.transpose(dt.Rows.OfType(Of DataRow)().[Select](Function(k) CObj(k(dc.ColumnName))).ToArray())

        Next

PS:此代码继续在当前应用程序中运行,因为仅在少数情况下我有超过 15000 条记录,但我需要一个明确的解决方案来解决这个问题。 ;-)

有人可以帮我吗?

【问题讨论】:

    标签: excel vb.net export-to-excel


    【解决方案1】:

    在此例程中收到大量记录后,我可以验证此错误是否发生在特定情况下,并且不会再次发生。我相信这个错误可能是由 varchar 字段中的字符引起的。

    因此没有必要对常规进行更正。

    所以,感谢您阅读我的问题 ;-)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-21
      • 2017-01-18
      • 2014-03-02
      • 1970-01-01
      • 1970-01-01
      • 2014-08-21
      相关资源
      最近更新 更多