[英]How to move 10,000 rows of data from a Stored Procedure to excel using c# winform
The situation is as follows - 情况如下 -
Current planned approach: 目前的计划方法:
How does the data get from the database to UserX's client? 数据如何从数据库传输到UserX的客户端?
I ask because the data sets are quite large and there may be unforeseen problems with certain approaches because of the size. 我问,因为数据集非常大,并且由于尺寸的原因,某些方法可能存在无法预料的问题。 Should the stored procs first move the data to actual server tables, then have a second step and move the data from the server tables into Excel?
如果存储过程首先将数据移动到实际的服务器表,那么还有第二步并将数据从服务器表移动到Excel中吗? Or should I just have the stored procedures return the datasets as it will be easy enough to move them direct into XL without any intermediate server tables?
或者我应该让存储过程返回数据集,因为它很容易将它们直接移动到XL而没有任何中间服务器表?
If you plan to fetch record thr' c#, 如果你打算获取记录thr'c#,
Instead of fetching 10000 or more records one at time, fetch specific no. 而不是一次获取10000条或更多条记录,而是获取特定的no。 of records eg 1000, 10 times.
记录,例如1000次,10次。 That will make process quicker & less memory load.
这将使流程更快,内存负载更少。
You don't need to create any intermediate server table to store dataset. 您无需创建任何中间服务器表来存储数据集。
Using DocumentFormat.OpenXml.Spreadsheet in c#, you can write that dataset to Xlsx format or create xml file using System.xml or use thrid party tool/create own excel xml, to create xls format. 使用c#中的DocumentFormat.OpenXml.Spreadsheet,您可以将该数据集写入Xlsx格式或使用System.xml创建xml文件或使用thrid party工具/创建自己的excel xml来创建xls格式。
I would suggest that you create .csv file from the results returned by your stored procedure at run-time using C#, a .csv file can be opened in Excel so you still have excel as the application at the end 我建议您使用C#在运行时从存储过程返回的结果创建.csv文件,可以在Excel中打开.csv文件,这样您仍然可以在应用程序结束时使用Excel作为应用程序
Also please see this link hence i did not recommend you using Automation of Office 另请参阅此链接,因此我不建议您使用Office自动化
Paragraph taken from http://support.microsoft.com/kb/257757 Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
从http://support.microsoft.com/kb/257757获取的段落 Microsoft目前不建议也不支持从任何无人参与的非交互式客户端应用程序或组件(包括ASP,ASP.NET)自动化Microsoft Office应用程序,DCOM和NT服务),因为Office在此环境中运行时可能会出现不稳定的行为和/或死锁。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.