[英]Most efficient way to extract data from multiple .xlsx files using Excel Interop in c#?
I have just started getting into Excel Interop and was wondering how I could improve the performance of my application by implementing either multithreading or multitasking.我刚刚开始接触 Excel Interop,想知道如何通过实现多线程或多任务来提高应用程序的性能。
My code looks something like this atm:我的代码看起来像这样的ATM:
foreach(var path in arrayOfExcelFilePaths){
excelApp.Workbooks.Open(path);
}
foreach(var wb in excelApp.Workbooks){
//Read stuff and maybe write stuff
}
Thanks in advance for anybody looking into this.提前感谢任何对此进行调查的人。
Using Interop is a bad idea in general.一般来说,使用互操作是一个坏主意。 The execution of your code won't differ much from its equivalent written in a VBA macro, because Interop simply runs the Excel process in the background and replicates its functionality 1-to-1.
您的代码的执行与在 VBA 宏中编写的等效代码没有太大区别,因为 Interop 只是在后台运行 Excel 进程并一对一地复制其功能。
Try OfficeOpenXML or any other library that allows you manipulate the content of excel sheets without running MS Excel as Interop does.尝试使用 OfficeOpenXML 或任何其他允许您操作 excel 工作表内容的库,而无需像 Interop 那样运行 MS Excel。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.