将Excel工作簿的第一列读入数组

时间:2015-03-25 14:56:52

标签: c# epplus-4

OpenFileDialog与EPPlus一起使用。我得到一个编译错误:

The name 'sheet' does not exist in the current context

现在,显而易见的问题是如何将选定的Excel文件与我的EPPPlus& 2如何删除上述错误?

using OfficeOpenXml;
using OfficeOpenXml.Drawing;

private void btn_ReadExcelToArray_Click(object sender, EventArgs e)
{
  fd.Filter = "Excel Files|*.xlsx";
  fd.InitialDirectory = @"C:\";
  if (fd.ShowDialog() == DialogResult.OK)
  {          
    var columnimport = sheet.Cells["A2:A"];
    foreach (var cell in columnimport)
    {
        var column1CellValue = cell.GetValue<string>();
    }
  }
}

0 个答案:

没有答案