tpow
tpow

Reputation: 7894

Accessing Excel in C# without OleDbConnection or Interop

I need to access an excel file, but the application needs to run on a server with no Office installation - so interop is out of the question.

I know there is OleDbConnection, which will work, but is having strange effect when reading in Header rows. When looking at headers, it will replace "." with "&" because it is treating the header as a database column name, and "." is unacceptable. So, I tried to read the headers in as data, but this caused certain columns to be null - particularly when using dates.

Anyway - looking for a way to read in Excel cell values without using these two methods?

P.S. Also trying to avoid 3rd party libraries - unless they're lightweight and free...

Upvotes: 1

Views: 1085

Answers (3)

Nathan Ridley
Nathan Ridley

Reputation: 34426

Try ExcelPackage. It's no longer in development but it still works very well and has a lot of people using it. For any bugs you come across, check out the discussions, as most people have come up with fixes and patches to any standard issues you find. Some of those have been submitted as patches.

Upvotes: 0

Wyatt Barnett
Wyatt Barnett

Reputation: 15663

Not too hard, though one package don't quite do it all.

.xls : ExcelLibrary
.xslx : ExcelPackage

Upvotes: 1

Pharabus
Pharabus

Reputation: 6062

you dont mention what you actually need it for, if you are querying there are some LINQ to Excel solutions

Linqtoexcel

just noticed you 3rd part restriction however the above may still be suitable

Upvotes: 4

Related Questions