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>();
}
}
}