crims0n
crims0n

Reputation: 3

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.

My code looks something like this 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.

Upvotes: 0

Views: 216

Answers (2)

jscarle
jscarle

Reputation: 1315

I highly recommend you use the EPPlus 5 library, which is a newer version of the EPPlus library. Its fast and reliable, I've been using it for years without any issues.

Upvotes: 0

user13348192
user13348192

Reputation: 69

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.

Try OfficeOpenXML or any other library that allows you manipulate the content of excel sheets without running MS Excel as Interop does.

Upvotes: 1

Related Questions