首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Gembox LoadXls IndexOutOfRangeException

Gembox LoadXls IndexOutOfRangeException
EN

Stack Overflow用户
提问于 2017-02-10 17:03:33
回答 1查看 547关注 0票数 1

我使用LoadXls从流上传文件,并得到以下错误:

代码语言:javascript
复制
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的位置设置为开始。

EN

回答 1

Stack Overflow用户

发布于 2021-09-15 13:19:41

马里奥Z的建议解决了这个问题。

尝试在阅读之前将MemoryStream的位置设置为开始,例如使用"memoryStream.Seek(0,SeekOrigin.Begin)“或"memoryStream.Position = 0;”

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42164829

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档