Link to home
Start Free TrialLog in
Avatar of sarad122
sarad122

asked on

How to create .xlsx file in c#?

How to create .xlsx file in c#, .net?
Avatar of Chinmay Patel
Chinmay Patel
Flag of India image

Hi Sarad,


If you want to avoid using COM component / InterOp/ unmanaged code, you can use 

1. https://github.com/tonyqus/npoi/

2. https://github.com/JanKallman/EPPlus

3. https://docs.microsoft.com/en-us/office/open-xml/open-xml-sdk


First two libraries are very easy to use and you can get it up and running in few lines of code. The Open XML SDK requires you to be bit experienced and is can get pretty complex if you want to do anything fancy with it.


Regards,

Chinmay.

I've used EPPlus, although in VB.NET, not C#. It's easy to use, and avoids many of the Interop troubles that I encountered.



I also stand clear from using Interops. On top of that, a lot of issues found when your application is using Excel at the same as your user. And if you need to run from a server, you will need to pay an Office licence and install it on the server.

I use https://products.aspose.com/cells/net
Hi,
C# is strong in handling Microsoft object (including Word, Excel, etc). See example code (in URL) below

https://www.e-iceblue.com/Tutorials/Spire.XLS/Spire.XLS-Program-Guide/Document-Operation/Create-Write-and-Save-Excel-File-in-WPF-with-C-VB.NET.html

C# is strong in handling Microsoft object (including Word, Excel, etc). See example code (in URL) below

That's assuming you have a license for the Spire products, which can get costly. Not to say it won't work - I'm sure it will - but EPPlus is free and does a great job

This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.