我使用LoadXls从流上传文件,并得到以下错误:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IndexOutOfRangeException: Index was outside the bounds of the array.
at External.CompoundFile.ReadData.(BinaryReader , ArrayList& )
at External.CompoundFile.ReadData..ctor(Ole2CompoundFile , Stream )
at External.CompoundFile.Ole2CompoundFile.Load(Stream , Boolean )
at GemBox.Spreadsheet.XlsLoadOptions.(Stream , Boolean , Byte[]& , Byte[]& , Boolean , Byte[]& , Byte[]& , Ole2Storage& )
at GemBox.Spreadsheet.XlsLoadOptions.(ExcelFile , Stream )
at GemBox.Spreadsheet.LoadOptions.(ExcelFile , Stream , String )
at GemBox.Spreadsheet.LoadOptions.(ExcelFile , Stream , String , Boolean )
at GemBox.Spreadsheet.ExcelFile.LoadXls(Stream stream)我使用的是GemBox.SpreadSheet.dll版本41.3.30.1047 (免费许可)。
这条小溪有什么问题吗?这是我通过直接从云存储服务(AWS S3、Bluemix、、Azure)获得流创建的一个MemoryStream。
这里是我正在尝试加载的xls
解决方案:解决方案最终是在阅读之前将MemoryStream的位置设置为开始。
发布于 2021-09-15 13:19:41
马里奥Z的建议解决了这个问题。
尝试在阅读之前将MemoryStream的位置设置为开始,例如使用"memoryStream.Seek(0,SeekOrigin.Begin)“或"memoryStream.Position = 0;”
https://stackoverflow.com/questions/42164829
复制相似问题