0

I have a Windows Form Application in VS2012 C# and I'm trying to use Microsoft.Office.Interop.Excel; in order to make an Excel spreadsheet. Whenever I try to type some code such as

Application _excelApp;

or

var application = new Application();

I keep getting the same error which is "Application is an ambiguous reference between 'System.Windows.Form.Application' and 'Microsoft.Office.Inter.Excel.Application'. I was just wondering what the solution is so I could start using the Interop.Excel. Any help would be greatly appreciated.

4

1 回答 1

6

使用完全限定的类型名称(包括命名空间)或使用命名空间别名。

using Excel = Microsoft.Office.Interop.Excel; // In your usings

var application = new Excel.Application();

或者

var application = new Microsoft.Office.Interop.Excel.Application();
于 2013-06-05T19:38:04.963 回答