如何从ZipArchiveEntry EPPlus C#获取xls文件 [英] how to get xls file from a ZipArchiveEntry EPPlus C#
问题描述
我正在尝试从ZipArchive获取xls文件,但无法通过EPPLUS获取它
i'am trying to get an xls file from an ZipArchive but cant get it with EPPLUS
foreach (ZipArchiveEntry entry in archive.Entries)
{
if (entry != null)
{
string filepath = entry.FullName;
FileInfo fileInfo = new FileInfo(filepath);
//here i got the excel package with the xls file inside the excelPackage
using (ExcelPackage excelPackage = new ExcelPackage(fileInfo))
{
//but here impossible de get the worksheet or workbook inside or anything else
ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets.FirstOrDefault();
int totalColomn = worksheet.Dimension.End.Column;
int nbrsheet = excelPackage.Workbook.Worksheets.Count();
}
}
}
我进入调试状态的ExcelPackage 我在excelpackage中看到了调试时的xls文件,但是当我尝试获取工作表时,它没有异常代码就退出了..
the ExcelPackage i get in debug i see the xls file on debug inside the excelpackage but just when i try to get worksheet it exit without exception code....
与entryStream尝试时在这里相同
same here when trying with entryStream
using (var entryStream = entry.Open())
{
//Cant even get the excelpackage, it crash here without exception
using (ExcelPackage excelPackage = new ExcelPackage(entryStream))
{
ExcelWorksheet worksheetest = excelPackage.Workbook.Worksheets.FirstOrDefault();
}
}
这里的溪流似乎也很奇怪... entryStream调试
the stream here seem also strange ... entryStream Debug
使用.NET CORE Blazor ServerSide,ePPLUS 4.5
Working with .NET CORE Blazor ServerSide, ePPLUS 4.5
感谢您的帮助
推荐答案
我找到了问题.
那是我试图获取一个xls文件,而epplus库无法使用它...您必须要小心,EPplus不能使用xls文件
it was that i tried to get an xls file and the epplus library dont work with it... you have to be careful, EPplus dont work with xls file
所以,您的解决方案Jeff正在工作,这是我的错,没有指定我的excel文件的扩展名...对不起
So , your solution Jeff is working, it was my fault, didn't specified the extension of my excel file... sorry
->带有.xlsx OK而不是.xls
-> EPlus with an .xlsx OK, not .xls
我的坏.还是谢谢你:-)
My bad. Thanks anyway :-)
这篇关于如何从ZipArchiveEntry EPPlus C#获取xls文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!