I have started using the Excel interop assemblies that are provided by Microsoft for one of my C# applications. Everything is going fine, but there seems to be a lack of strong typing, and honestly it feels like I am writing VBA code. Are there any alternative ways to interact with Excel from C# that would give a better OO experience? I am using VS2010 and .Net 4.0 by the way.
Probably yes, but it really depends on the complexity of the sheet. It is more efficient to use OpenXML SDK then Interop, but the code is a bit more complicated. Also both OpenXML SDK and Excel Interop are third party libraries. If you do not want to use any third party library then you would need to use System.
Some issues when using Microsoft Office Interop (Excel Automation) from C# or VB.NET are: It requires a license for Microsoft Office on every client machine. It requires all client machines to have the same version of Microsoft Excel installed.
Office. Interop. Excel' nuget package, and then add reference to 'Microsoft Excel 16.0 Object Library' (right click the project -> 'Add' -> 'Reference' -> search and add 'Microsoft Excel 16.0 Object Library' ). Click ''Interop.
Take a look at the EPPlus project over at Codeplex:
http://epplus.codeplex.com/
I recently used this and it worked very well. (VS2010 and .Net4)
EPPlus is a .net library that reads and writes Excel 2007/2010 files using the Open Office Xml format (xlsx).
Nice example page: http://epplus.codeplex.com/wikipage?title=ContentSheetExample
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With