0

我已经搜索了 SO 寻求帮助,我想我已经用尽了所有选择。

我有一个生成大约 320k 行的报告,并且导出到 Excel 非常慢。太慢了,即使在渲染结束后(如上所示ExecutionLog3),甚至都没有创建 excel 文件。

我已经删除了报告标题,甚至可以导出到不同的工作表以创建一个较小的 Excel 文件,并且没有合并单元格。所有列都没有任何格式。缓慢导出到 Excel 的常见罪魁祸首,对吧?

这是来自的输出ExecutionLog3

TimeStart               TimeEnd                 TimeDataRetrieval_Secs  TimeProcessing_Secs TimeRendering_Secs  TotalTime_Secs  ReportSizeMB    RowCount    Status      Format          Source
2019-06-12 09:20:57.310 2019-06-12 09:32:41.313 0.000000                0.047000            703.907000          703.954000      55.596719       0           rsSuccess   EXCELOPENXML    Session
2019-06-12 09:17:44.433 2019-06-12 09:20:01.220 33.336000               103.222000          0.080000            136.638000      0.502475        323800      rsSuccess   RPL             Live

这是 EXCELOPENXML 的 AddionalInfo 列的输出

<AdditionalInfo>
  <ProcessingEngine>2</ProcessingEngine>
  <ScalabilityTime>
    <Pagination>0</Pagination>
    <Rendering>0</Rendering>
    <Processing>0</Processing>
  </ScalabilityTime>
  <EstimatedMemoryUsageKB>
    <Pagination>32831</Pagination>
    <Rendering>356162</Rendering>
    <Processing>55997</Processing>
  </EstimatedMemoryUsageKB>
  <Connections />
</AdditionalInfo>

作为比较,使用 Excel 本身内部的“从 SQL 数据库获取数据”功能并使用相同的参数执行相同的 SP - 整个过程大约需要 72 秒才能加载数据并在 Excel 中显示。

关于如何改善这种出口的任何想法?

4

2 回答 2

0

I've found this solution very helpful :

https://social.technet.microsoft.com/Forums/ru-RU/124d54f4-583c-4d6d-ac93-4a8e2971b438/export-to-excel-takes-long-time-in-ssrs-2008?forum=sqlreportingservices

here is a general Idea about this solution :

In Reporting Services, when exporting a report, the report is passed as an interim format to a specific renderer. For excel which was processed by a powerful and complicate engine, which provide brilliant appearance and rich features, as a result, it would cost longer time to export so large quantity of data. For your requirement, we can use the following steps to improve the performance of exporting to excel:

1- Do not merge cells in a Tablix data region.

2- Consider using page breaks in the report.

3- Select a format that produces a smaller file, like CSV. Since it is just a flat text file, it has a fast write speed, we can export the report to csv format and then open it with excel.

于 2021-03-08T08:10:35.617 回答
0

从 SQL Server 导入 Excel 并在 Excel 中进行聚合、图表、绘图等。下面的示例代码将从 SQL Server 获取数据并将其拉入 Excel。

Sub TestMacro()

' Create a connection object.
Dim cnPubs As ADODB.Connection
Set cnPubs = New ADODB.Connection

' Provide the connection string.
Dim strConn As String

'Use the SQL Server OLE DB Provider.
strConn = "PROVIDER=SQLOLEDB;"

'Connect to the Pubs database on the local server.
strConn = strConn & "DATA SOURCE=(local);INITIAL CATALOG=NORTHWIND.MDF;"

'Use an integrated login.
strConn = strConn & " INTEGRATED SECURITY=sspi;"

'Now open the connection.
cnPubs.Open strConn

' Create a recordset object.
Dim rsPubs As ADODB.Recordset
Set rsPubs = New ADODB.Recordset

With rsPubs
    ' Assign the Connection object.
    .ActiveConnection = cnPubs
    ' Extract the required records.
    .Open "SELECT * FROM YourTable"
    ' Copy the records into cell A1 on Sheet1.
    Sheet1.Range("A1").CopyFromRecordset rsPubs

    ' Tidy up
    .Close
End With

cnPubs.Close
Set rsPubs = Nothing
Set cnPubs = Nothing

End Sub
于 2019-06-12T12:55:58.453 回答