C# – Looking for a value in Excel with C# & VisualStudio

Using Visual Studio and Excel is actually quite fun – the Visual Studio advanced environment provides a bit more possibilities than the Visual Basic Editor, built-in Excel. In this article, about a year ago I have shown how to loop through Excel files with a C# program. The task today is to build a small program, which opens an Excel file, searches within for a given word and returns information about the column and the row on which the word was found.

Thus, as far as the console applications become rather boring and I cannot make fancy screenshots with them, I have decided to build a small project with Windows Form. This is how the interface looks like:

No fancy UI/UX design, simply a browse button to select the path of the file, which is displayed through a label. Then the word, which should be looked for is entered in the textBox and once the “GO” button is clicked, the excel file is opened and the results are displayed:

Of course, it is possible not to find the word we are searching for. Thus we get this:

So far so good. The whole project is accessible in GitHub here, but still some of the code follows:

Enjoy the code!

About

VBA Developer

Tagged with: , , ,