Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# read excel worksheet

Tags:

c#

excel

Could someone help me read a simple excel worksheet in c# app? I'd like to be able to iterate each row and have a handle on each of the columns.

Thanks, rod.

like image 213
Rod Avatar asked Nov 21 '10 01:11

Rod


2 Answers

This one is the easiest method I have found:

Create Excel (.XLS and .XLSX) file from C#

like image 154
Leniel Maccaferri Avatar answered Oct 01 '22 08:10

Leniel Maccaferri


The general method is to use Excel COM Interop. A quick google will find plenty of tutorials. Here's one for creating a sheet - it should point you in the direction (reading is pretty much the same).

An alternative method is to use ADO.Net. This is only really viable if your Excel sheet is well formed as a table ( ie. Database), but is easier than the interop approach.

like image 42
winwaed Avatar answered Oct 01 '22 10:10

winwaed