Read and write excel file in CSharp – C# using Office library

Monday, April 3rd, 2017 (0 Comment)

In this article, we will do simple exercise about read and write excel file in CSharp – C# using office library. We can read and write excel file 2003 or over 2007.

We need to install office and add library to your project. We will add Microsoft.Office.Interop.Excel on the Assemblies page to References of project.

At first, we have to create excel file with Sheet1 as below:

1) Read excel file in CSharp – C#

Using library to read excel file in CSharp  – C#

Function read excel file in CSharp  – C#

  • Line 1: you need list array object to store values when read excel file and then using for write excel file in CSharp – C#

Output:

2) Write excel file in CSharp – C#

Output:

We have 2 sheet in a new excel file xlsx.

Tags: , , , ,

Related Posts

csharp
How to send mail csharp – C#
csharp
Connection to ldap in csharp – C# simple
csharp
How to call lua in CSharp – C#
csharp
Convert object to json in CSharp – C# and vice versa

Related Posts

csharp
How to send mail csharp – C#
csharp
Connection to ldap in csharp – C# simple
csharp
How to call lua in CSharp – C#
csharp
Convert object to json in CSharp – C# and vice versa

Leave a Reply

Your email address will not be published. Required fields are marked *