using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;//下面这三个名称空间需要引用
using MSword = Microsoft.Office.Interop.Excel;
using Microsoft.Office.Core;
using System.IO;
namespace ConsoleApp18
{classProgram{staticvoidMain(string[] args){
string path2 = System.Environment.CurrentDirectory;/在C#中”\“是转bai义符,所以当你写"c:\dos"时,C#会把”\d“当du成转义符,所以加上@,C#就会认成"c:\dos"。
string ex = @"\1.xls";
string fileName = path2 + ex;//新建一个应用程序EXC1
MSword.Application EXC1=newMSword.Application();EXC1.Visible =true;//设置EXC1打开后可见
MSword.Workbooks wbs =EXC1.Workbooks;
MSword._Workbook wb = wbs.Add(fileName);//打开并显示EXCEL文件//wb.Close();//关闭文档//wbs.Close();//关闭工作簿//EXC1.Quit();//关闭EXCEL应用程序//释放EXCEL应用程序的进程//System.Runtime.InteropServices.Marshal.ReleaseComObject(EXC1);}}}