我正在使用 EPPlus 库的 3.1 版本来尝试访问 Excel 文件中的工作表。当我尝试以下任一方法时,我得到一个System.ArgumentException : An item with the same key has already been added
.
using (ExcelPackage package = new ExcelPackage(new FileInfo(sourceFilePath)))
{
var worksheet = package.Workbook.Worksheets[0];
// OR
foreach (var excelWorksheet in package.Workbook.Worksheets)
...
}
异常堆栈:
System.ArgumentException : An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at OfficeOpenXml.ExcelNamedRangeCollection.Add(String Name, ExcelRangeBase Range)
at OfficeOpenXml.ExcelWorkbook.GetDefinedNames()
at OfficeOpenXml.ExcelPackage.get_Workbook()
这似乎是非常基本的功能已经被破坏了..我做错了什么吗?