Is there a free or open source library to read Excel files (.xls) directly from a C# program?
It does not need to be too fancy, just to select a worksheet and read the data as strings. So far, I've been using Export to Unicode text function of Excel, and parsing the resulting (tab-delimited) file, but I'd like to eliminate the manual step.
Late to the party, but I'm a fan of LinqToExcel
Lately, partly to get better at LINQ.... I've been using Excel's automation API to save the file as XML Spreadsheet and then get process that file using LINQ to XML.
Koogra is an open-source component written in C# that reads and writes Excel files.
Not free, but with the latest Office there's a very nice automation .Net API. (there has been an API for a long while but was nasty COM) You can do everything you want / need in code all while the Office app remains a hidden background process.
The solution that we used, needed to:
There are several choices, but we found NPoi (.NET port of Java's long existing Poi open source project) to be the best: http://npoi.codeplex.com/
It also allows working with .doc and .ppt file formats
I did a lot of reading from Excel files in C# a while ago, and we used two approaches:
The latter approach was much faster: reading a big table with 20 columns and 200 lines would take 30 seconds via COM, and half a second via ODBC. So I would recommend the database approach if all you need is the data.
Cheers,
Carl