简体   繁体   English

模拟从Sharepoint检索Excel文件

[英]Simulate retrieving Excel file from Sharepoint

When I open an Excel file stored on Sharepoint, I have the option to open it Read Only or in Edit mode. 当我打开存储在Sharepoint上的Excel文件时,可以选择以“只读”或“编辑”模式打开它。 If I open it Read Only, Excel opens up and I see "Server Workbook To modify this workbook, click Edit Workbook". 如果我将其打开为只读,则会打开Excel,并且会看到“服务器工作簿,要修改此工作簿,请单击编辑工作簿”。 I need to retrieve this Excel file through an ASP.NET application, yet still have this Server Workbook functionality. 我需要通过ASP.NET应用程序检索此Excel文件,但仍然具有此Server Workbook功能。

In fiddler, I see that when opening up in Sharepoint, a POST is made to SharepointSite/_vti_bin/_vti_aut/author.dll with method=getdocument as one of the parameters sent and the filename as another. 在提琴手中,我看到在Sharepoint中打开时,将对sharepointSite / _vti_bin / _vti_aut / author.dll进行POST,其中method = getdocument作为发送的参数之一,而文件名则作为另一个参数。

Do I need to repeat that POST via an ajax call or is there an easier way (as I suspect there is)? 我是否需要通过ajax调用重复该POST,还是有更简单的方法(我怀疑有这种方法)?

After reviewing this post and finding that he just followed the javascript and called function editDocumentWithProgID2 , I did almost that very thing. 在查看了这篇文章并发现他只是遵循javascript并调用了函数editDocumentWithProgID2之后 ,我几乎完成了那件事。 I just switched from that function to the ViewDoc javascript function. 我只是从该函数切换到了ViewDoc javascript函数。

<a onclick="javascript: ViewDoc('http://mysite/myfile.xlsx', 'SharePoint.OpenDocuments');"...

This required that I add the link to the Sharepoint javascript file Core.js on my page: 这要求我将链接添加到页面上的Sharepoint javascript文件Core.js:

<script src='http://mysite/_layouts/1033/core.js' type="text/javascript"
        language="javascript"></script>

Now after clicking the link, the spreadsheet pops up and has the "Server Workbook" with the "Edit Workbook" button 现在,单击链接后,电子表格会弹出,并带有“服务器工作簿”和“编辑工作簿”按钮

I wouldn't really recommend anyone copy it, since it is pretty brittle and will break if/when we upgrade to Sharepoint 2010, and that it couples the ASP.NET and Sharepoint sites. 我真的不建议任何人复制它,因为它非常脆弱,如果/当我们升级到Sharepoint 2010时会损坏,并且它将ASP.NET和Sharepoint站点耦合在一起。 It does the job that we need it for right now, however. 但是,它完成了我们目前所需的工作。

rather than simulating the a browser function, which may break in the future, the preferred method is to either use the sharepoint object model or the sharepoint web services to retrieve the file. 与其模拟将来可能会中断的浏览器功能,不如选择一种方法,即使用共享点对象模型或共享点Web服务来检索文件。

you can use the lists webservices for your check in/out functions if that is what you are referring to. 您可以使用列表Web服务进行签入/签出功能(如果您要使用的是此功能)。 http://msdn.microsoft.com/en-us/library/lists.lists_members%28v=office.12%29.aspx http://msdn.microsoft.com/zh-cn/library/lists.lists_members%28v=office.12%29.aspx

unless I misunderstood your question. 除非我误解了你的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM