How to open excel and add empty workbook with C#

1 Answer

0 votes
/*
Create: Visual C# - Console Application Project
Right click on: References 
Select: Add references...
Select: com
Select: Microsoft Office 12.0/15.0/16.0 Object Library
In References list you will see: Microsoft.Office.Interop.Excel
*/

using System;
using Excel = Microsoft.Office.Interop.Excel;

namespace WorkWithExcel
{
	class ExcelClass
	{
		static void Main(string[] args)
		{
			Excel.Application excelApp = new Excel.Application();  
			excelApp.Visible = true;  

            try
            {

                Excel.Workbook newWorkbook = excelApp.Workbooks.Add();
            }
            catch
            {
                Console.WriteLine("Error open new workbook");
            }
		}
	}
}

 



answered Nov 27, 2015 by avibootz

Related questions

1 answer 387 views
1 answer 344 views
2 answers 649 views
2 answers 438 views
2 answers 402 views
402 views asked Nov 27, 2015 by avibootz
1 answer 314 views
314 views asked Aug 10, 2018 by avibootz
2 answers 266 views
266 views asked May 26, 2024 by avibootz
...