Reputation: 177
I hope someone can point me in the right direction. I'm planning to build a web application using Webforms in ASP.NET. In the application, I'll be interacting with Excel files stored in a shared folder to compute the desired output and show the output in the front end. So far, I can accomplish the desired output using the VLOOKUP
functions manually, but I have no idea on how to accomplish the same thing using C#.
Am I looking at this in the wrong perspective, if so, are there any better ways to accomplish the same result?
Upvotes: 1
Views: 795
Reputation: 668
This can be done using OleDB, an API made by Microsoft to access data from various datasources. This method saves you the pain of manually accessing an Excel file and parsing the data. Using the OleDb connection will also give you metadata information about the excel file, its tables and columns etc.
There are plenty of tutorials on this out there, here's one of them: OleDb Excel Tutorial. This will teach you everything you need to achieve your goal.
The basic steps to get data through an OleDbConnection are:
Connectionstrings.com shows you how to form connection strings for many different datasources, including Excel through OleDb.
You need to download and install the OleDb Access driver from Microsoft, which you can get at their website https://www.microsoft.com/en-us/download/details.aspx?id=54920 (it's called "Access driver", but it enables data access for most Microsoft Office system files)
Upvotes: 5