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 270 views
1 answer 233 views
2 answers 510 views
2 answers 313 views
2 answers 265 views
265 views asked Nov 27, 2015 by avibootz
1 answer 212 views
212 views asked Aug 10, 2018 by avibootz
2 answers 123 views
123 views asked May 26, 2024 by avibootz
...