从 Sharepoint 中存储的 Excel 文档读取数据?
如何“读取”存储为共享点 spfile 的 Excel 2003 文档?我可以使用 SPFile.OpenBinary() 从库中毫无问题地检索文档,然后将其放入 MemoryStream 中。
最初的想法是使用 OpenXML 来查询文档(它将将此对象类型作为构造函数),但 Excel 版本(2003)禁止这样做。
只是为了进一步解决这个问题,无法保证我的主机上会有任何 Excel 版本,因此可能也无法使用互操作程序集。
我们将不胜感激地收到建议或解决方案。
当我说读取时,我的意思是从命名范围、单元格引用等中提取数据。我发现的所有开源库(Exceldatareader、NOPI、OpenXML)都有一些限制或其他禁止使用它们的限制。例如,无法加载启用宏的工作表
Excel 文档被加载到共享点库中,该库将此列表公开为 SPFile 的集合。这些文件可以很简单地读入 MemoryStream,但我尝试过的大多数库都需要文件流构造函数,这意味着写入应用程序服务器上的文件系统
我没有尝试过 SpreadsheetGear,但如果文件系统上没有足迹,那我肯定会看一下,但这不是这个项目的选择。我将用我的发现更新此线程...
我只能使用 PIA。肮脏,肮脏,肮脏。
How can I 'read' an excel 2003 document stored as a sharepoint spfile? I can retrieve the document from the library with no problems using the SPFile.OpenBinary() and then putting that into a MemoryStream.
The original idea was to use OpenXML to interrogate the document (which will take this object type as a constructor), but the Excel version (2003) prohibits this.
Just to cloud the issue further, there is no guarantee that I will have any Excel version on the host machine, so possibly won't be able to use the interop assemblies either.
Suggestions or solutions will be gratefully received.
When I say read, I mean pull data from named ranges, cell references etc. All of the open source libraries I have found (Exceldatareader, NOPI, OpenXML) have some limitation or another that prohibits their use. e.g. can't load macro enabled sheets
The excel document is loaded into a sharepoint library which exposes this list as a collection of SPFile(s). These files can be read into a MemoryStream simply enough, but most of the libraries I have tried require a filestream constructor, which means writing to the filesystem on the application server
I've not tried SpreadsheetGear, but if there's no footprint on the filesystem, then I'll take a look for sure, but this is not an option on this project. I'll update this thread with my findings...
I'm reduced to using the PIA's. Dirty, dirty, dirty.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
SpreadsheetGear for .NET 可以使用 SpreadsheetGear.Factory.GetWorkbookSet() 从内存流中打开 xls 和 xlsx 工作簿.Workbooks.OpenFromStream(System.IO.Stream) 还能够使用 OpenFromMemory(byte[]) 直接从字节数组打开。一旦打开,SpreadheetGear就有完善的API、计算引擎、渲染引擎等等。
您可以此处查看实时示例并下载免费试用版此处。
免责声明:我拥有 SpreadsheetGear LLC
SpreadsheetGear for .NET can open a xls and xlsx workbooks from a memory stream with SpreadsheetGear.Factory.GetWorkbookSet().Workbooks.OpenFromStream(System.IO.Stream) and also has the ability to open directly from a byte array with OpenFromMemory(byte[]). Once opened, SpreadheetGear has a comprehensive API, calculation engine, rendering engine and more.
You can see live samples here and download the free trial here.
Disclaimer: I own SpreadsheetGear LLC
我在 codeplex 上找到了这个[库] (http://exceldatareader.codeplex.com/)似乎可以读取任何Excel版本。网上可能还有很多
I've found this [library] (http://exceldatareader.codeplex.com/) on codeplex which seems to be able to read any Excel version. There might be a lot more on the web
当你说阅读时,你到底是什么意思?对于该术语的定义,开发人员之间似乎存在一些激烈的争论。不管怎样,Excel 是否在他们的系统上并不重要,因为我非常确定,如果人们想以任何方式查看文件,他们至少需要一个阅读器。话虽这么说,我相信你的恐惧是一个没有实际意义的问题,使用 MemoryStream 应该就足够了。
When you say read what exactly do you mean? There seems to be some great debate amongst developers as to what the term's definition is. Either way it shouldn't really matter if Excel is on their system or not, on account of I am only pretty sure that if the person wanted to view the file any way they would need at the very least a reader. So that being said I believe your fear is a moot point and that using a MemoryStream should suffice.