[英]How can I automate the checkout of an excel spreadsheet from a sharepoint document library, edit the spreadsheet, and check it back in?
I have a couple of hundred excel spreadsheets that are stored in a SharePoint 2010 document library.我有几百个 Excel 电子表格存储在 SharePoint 2010 文档库中。
A good many of these spreadsheets have hard coded URLs that need to be updated to new URLs based on some re-structuring of our SharePoint site.这些电子表格中有很多都有硬编码的 URL,需要根据我们的 SharePoint 网站的一些重新结构将其更新为新的 URL。
I would like to iterate through all of the spreadsheets, open them and do a search and replace and then write them back into SharePoint.我想遍历所有电子表格,打开它们并进行搜索和替换,然后将它们写回 SharePoint。
For the record, I already know how to iterate the excel spreadsheets in SharePoint (creating reference to SPFile) and run the checkout and checking commands.作为记录,我已经知道如何在 SharePoint 中迭代 Excel 电子表格(创建对 SPFile 的引用)并运行结帐和检查命令。
I am almost very comfortable with doing the OLE Automation of Excel to do the find and replace.我几乎很擅长使用 Excel 的 OLE 自动化来进行查找和替换。
I am struggling with how to bridge the gap between the two.我正在努力寻找如何弥合两者之间的差距。 After I grab a reference to a file and check it out, how can I do ole automation on it?
在我获取对文件的引用并将其检出后,如何对其进行 ole 自动化? Normally I believe that to open a reference to a file I would need a file path but even if I check out with the "use local" option there is not a file created into the file system (and even if there is I am not convinced that it would work to work with the temp file.)
通常我相信要打开对文件的引用,我需要一个文件路径,但即使我使用“使用本地”选项签出,也没有在文件系统中创建文件(即使有我也不相信它可以与临时文件一起使用。)
It seems that I should be able to load it from a stream into a VBA Excel Automation object but I am not sure how.似乎我应该能够将它从流加载到 VBA Excel 自动化对象中,但我不确定如何。
Any thoughts?有什么想法吗?
Let's say you build this tool as a Console Application, which you run on the SharePoint server.假设您将此工具构建为在 SharePoint 服务器上运行的控制台应用程序。 In the Console Application code:
在控制台应用程序代码中:
I should point out that some server administrators will not allow Automation code to run on the server itself.我应该指出一些服务器管理员不允许自动化代码在服务器本身上运行。 In this case, run the Console Application on a client machine and use the SharePoint Lists webservice to do the check-in and check-out.
在这种情况下,在客户端计算机上运行控制台应用程序并使用 SharePoint 列表 Web 服务进行签入和签出。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.