Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 尝试使用ePlus从ZipArchive读取Excel文件_C#_Epplus - Fatal编程技术网

C# 尝试使用ePlus从ZipArchive读取Excel文件

C# 尝试使用ePlus从ZipArchive读取Excel文件,c#,epplus,C#,Epplus,我正在尝试从zip存档中读取excel文件: var excelEntry = archive.Entries.Single(entry => Regex.IsMatch(entry.FullName, @"\.xlsx\z", RegexOptions.IgnoreCase)); using (var excelPackage = new ExcelPackage(excelEntry.Open())) { } 然而,我得到了一个NotSupportedException (Excep

我正在尝试从zip存档中读取excel文件:

var excelEntry = archive.Entries.Single(entry => Regex.IsMatch(entry.FullName, @"\.xlsx\z", RegexOptions.IgnoreCase));
using (var excelPackage = new ExcelPackage(excelEntry.Open()))
{
}
然而,我得到了一个NotSupportedException

(Exception thrown: 'System.NotSupportedException' in System.dll
Additional information: This operation is not supported.) 
该文件是一个简单的.xlsx文件,没有任何保护。
有什么想法吗?

这确实是因为zip存档流是只读的,而ExcelPackage只接受读/写流

我做了以下调整:

var entryStream = excelEntry.Open();
using (var ms = new MemoryStream())
using (var excelPackage = new ExcelPackage())
{
  entryStream.CopyTo(ms);
  excelPackage.Load(ms);
  ...
}

现在我看到ziparchive处于读取模式,可能与需要读/写流的ExcelPackage有关?非常感谢您的解决方案!