如何解决在C#中找不到的方法?

我正在尝试阅读一个xlsx文件,并从这个Codeproject链接中获得了一个基本的概述
现在,我收到以下exception消息:
异常消息
与此exception相关的代码段如下所示:

public static sst SharedStrings; /// <summary> /// All worksheets in the Excel workbook deserialized /// </summary> /// <param name="ExcelFileName">Full path and filename of the Excel xlsx-file</param> /// <returns></returns> public static IEnumerable<worksheet> Worksheets(string ExcelFileName) { worksheet ws; using (ZipArchive zipArchive = ZipFile.Open(ExcelFileName, ZipArchiveMode.Read)) { SharedStrings = DeserializedZipEntry<sst>(GetZipArchiveEntry(zipArchive, @"xl/sharedStrings.xml")); foreach (var worksheetEntry in (WorkSheetFileNames(zipArchive)).OrderBy(x => x.FullName)) { ws = DeserializedZipEntry<worksheet>(worksheetEntry); ws.NumberOfColumns = worksheet.MaxColumnIndex + 1; ws.ExpandRows(); yield return ws; } } } 

经过一番search,我发现我需要瞄准.NET 4.5或以上的版本,(我的目标是4.6.1,但我也尝试过4.5,仍然是相同的结果)。 而且,就依赖关系而言,我的引用如下所示:
参考图像
做完所有这些之后,我仍然得到上面提到的exception,不知道为什么会发生这种情况。
编辑1:我已经通过这个StackOverflow链接 ,我觉得我需要最新的DLL。 我去了Nuget软件包pipe理器,并且find了“没有find软件包”这些可用于更新的软件包。

我已经尝试过.NET 4.6.14.6.2. 两者都可以为我工作。

我的Visual StudioCommunity Edition 2017

项目参考:

在这里输入图像说明

请注意 System.IO.Compression.ZipFile 未被引用。 在我的环境中不可能引用它。

使用Workbook.Worksheets()或将调用类声明为Excel.Workbook子类。

Excel是CodeProject文章来源的命名空间,它提供了必要的类。

 using Excel; using System; namespace akExcelAsZipDemo { class Program : Workbook { // from // https://www.codeproject.com/tips/801032/csharp-how-to-read-xlsx-excel-file-with-lines-ofthe // // inspired: // https://github.com/ahmadalli/ExcelReader static void Main(string[] args) { const string fileName = @"E:\AK\export.xlsx"; var worksheets = Worksheets(fileName); foreach (worksheet ws in worksheets) { Console.WriteLine($"cols={ws.NumberOfColumns} rows={ws.Rows.Length}"); } Console.WriteLine(); } } }