Visual Studio 2017 c# 导出数据到 Excel

Visual Studio 2017 c# export data to Excel

我正在尝试将数据从数组导出到 Excel 工作表。

在这里找到了关于如何操作的非常好的教程:

http://csharp.net-informations.com/excel/csharp-create-excel.htm

已添加对 Microsoft Excel 16.0 对象库 v1.9 的引用

然而,当我尝试输入 "excel" 时,我没有得到 Excel 的任何属性或方法,我猜这表明我使用了错误的关键字。

任何人都知道我应该做什么。

private void btnExcel_Click(object sender, EventArgs e)
{
    Excel. <- ??????        
} 

您是否在文件顶部添加了 using 语句?有关详细信息,请参阅 here

using Excel = Microsoft.Office.Interop.Excel;

叫做Namespace alias,你可以这样实现

using Excel = Microsoft.Office.Interop.Excel;