开发者

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 lightwe开发者_开发百科ight and free...


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


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

.xls : ExcelLibrary
.xslx : ExcelPackage


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜