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 392 views
1 answer 350 views
2 answers 660 views
2 answers 449 views
2 answers 412 views
412 views asked Nov 27, 2015 by avibootz
1 answer 322 views
322 views asked Aug 10, 2018 by avibootz
2 answers 277 views
277 views asked May 26, 2024 by avibootz
...