---
title: "Writing Data to EXCEL Sheet using C#"  
description: "Explain how to write data into the excel sheet using C#."  
author: "Sanjay Singh"  
published: 2012-01-05  
updated: 2020-03-15  
canonical: https://www.mindstick.com/articles/853/writing-data-to-excel-sheet-using-c-sharp  
category: "c#"  
tags: ["excel"]  
reading_time: 1 minute  

---

# Writing Data to EXCEL Sheet using C#

Hi Friends, today into this Article I am going to explain how to write data into an excel sheet using C#. First of all right click on **References-> Add references-> Choose COM Tab-> Select Microsoft Excel 12.0 Object Library** and write the following code.

```
using System;using System.Collections.Generic;using System.Linq;using System.Text;using Microsoft.Office.Core;using Excel=
Microsoft.Office.Interop.Excel; namespace EXCEL_DATA{    class Program    {              static void Main(string[] args)        {            Excel._Application myExcelApp;            Excel.Workbooks myExcelWorkbooks;            Excel.Workbook myExcelWorkbook;           // Excel ._Worksheet myExccelWorksheetToChange;            object misValue = System.Reflection.Missing.Value;             myExcelApp = new Excel.ApplicationClass();             myExcelApp.Visible = true; myExcelWorkbooks = myExcelApp.Workbooks; String fileName = "D:\\book1.xls";  myExcelWorkbook = myExcelWorkbooks.Open(fileName, misValue, misValue, misValue, misValue,
misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue,misValue,misValue);                  Excel.Worksheet myExcelWorksheet = (Excel.Worksheet)myExcelWorkbook.ActiveSheet;  String cellFormulaAsString = myExcelWorksheet.get_Range("A2", misValue).Formula.ToString();  myExcelWorksheet.get_Range("A1", misValue).Formula = Console.ReadLine();                               }    }} 
```

##### Output:

First Enter Something…..

![Writing Data to EXCEL Sheet using C#](https://www.mindstick.com/mindstickarticle/8abc2b55-713c-4552-9dca-b36a38c686a9/images/ff57f63d-f925-4ea1-8a0f-b2c4ab8c0deb.png)

Press ‘Enter’ key, data entered by you will display on Excel Worksheet.

![Writing Data to EXCEL Sheet using C#](https://www.mindstick.com/mindstickarticle/8abc2b55-713c-4552-9dca-b36a38c686a9/images/87c7c1da-4823-434b-8d28-bf1383c64de0.png)

X

---

Original Source: https://www.mindstick.com/articles/853/writing-data-to-excel-sheet-using-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
