[英]C# command line add reference to Microsoft.Office.Interop.Excel
需要使用C#使用Excel自动化。
没有安装Visual Studio,无法完成。 但是Ms-Office 2007安装在工作站上。
使用csc.exe进行编译时,由于Microsoft.Office程序集而出现错误。 我尝试在常规位置搜索,但找不到dll文件。
using Microsoft.Office.Interop.Excel;
using Excel = Microsoft.Office.Interop.Excel;
/// no files found
/// assembly paths ; C:\Windows\assembly\Microsoft.Office.Interop.Excel
/// C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5
class Program
{
static void Main(string[] args)
{
var excelApp = new Excel.Application();
excelApp.Workbooks.Add();
// Insert VBA code here.
excelApp.Visible = true;
}
}
您可以引用位于GAC csc / recurse:* / r中的DLL:“ C:\\ windows \\ assembly \\ GAC_MSIL \\ Microsoft.Office.Inte 5.0.0.0__71e9bce111e9429c \\ Microsoft.Office.Interop.Excel.dll”
根据您的Office版本,您最终必须更改路径
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.