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 284 views
1 answer 248 views
2 answers 528 views
2 answers 329 views
2 answers 277 views
277 views asked Nov 27, 2015 by avibootz
1 answer 227 views
227 views asked Aug 10, 2018 by avibootz
2 answers 144 views
144 views asked May 26, 2024 by avibootz
...