/*
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;
string WorkbookFilePath = "e:/test.xlsx";
Excel.Workbook excelWorkbook = null;
try
{
excelWorkbook = excelApp.Workbooks.Open(WorkbookFilePath, 0,
false, 5, "", "", false, Excel.XlPlatform.xlWindows, "",
true, false, 0, true, false, false);
}
catch
{
Console.WriteLine("Error open: " + WorkbookFilePath);
}
}
}
}