Simple Excel Automation Using C#

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Reflection;

using System.Runtime.InteropServices;

using Xcel = Microsoft.Office.Interop.Excel;

 

 

namespace Excel

{

    class Program

    {

        static void Main(string[] args)

        {

            Xcel.Application excelApp = new Xcel.Application();

            object missing = System.Reflection.Missing.Value;

            Xcel.Workbook book;

            string myPath = @"C:\Excel.xlsx";

            book = excelApp.Workbooks.Open(myPath,

            missing, missing, missing, missing, missing, missing, missing,

            missing, missing, missing, missing, missing, missing, missing);

            int rowIndex = 1; int colIndex = 1;

            excelApp.Cells[rowIndex, colIndex] = "First";

            excelApp.Visible = true;

            book.Save();

            excelApp.Workbooks.Close();

        }

    }

}

 

Advertisements
This entry was posted in Information Technology. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s