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