[英]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.