简体   繁体   English

如何从 Sharepoint 文档库自动签出 Excel 电子表格、编辑电子表格并重新签入?

[英]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:在控制台应用程序代码中:

  1. Use the SharePoint object model to check-out the file使用 SharePoint 对象模型签出文件
  2. Use the .Net WebClient.DownloadFile method to download the file to your local system使用 .Net WebClient.DownloadFile方法将文件下载到本地系统
  3. Run your Automation code运行自动化代码
  4. Use the SharePoint object model to upload and check-in the modified file使用 SharePoint 对象模型上传和签入修改后的文件

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.

相关问题 借助Sharepoint 2010 Excel Services,如何从具有版本控制的电子表格中获取值 - With Sharepoint 2010 Excel Services how can I get values from a spreadsheet with version control 如何通过链接而不是图像文件通过Spreadsheet Light将图片插入Excel电子表格? - How can I insert a picture into an Excel spreadsheet with Spreadsheet Light from a link rather than an image file? 在Word文档中编辑Excel电子表格对象(C#Interop) - Edit Excel Spreadsheet object in word document (C# Interop) 如何直接将文档加载到 devexpress 电子表格而不保存在本地 - how can i directly load Document to devexpress spreadsheet not save in local 如何使用Linq写入Excel电子表格? - How can I write to an Excel spreadsheet using Linq? 如何提高OpenXml Excel电子表格工具中从SharedStringTable检索值的性能? - How can I improve the performance of retrieving values from SharedStringTable in OpenXml Excel spreadsheet tools? 如何从Excel电子表格中读取单个列? - How do I read in a single column from an Excel spreadsheet? 在devexpress winforms中,如何从数据源将数据导入电子表格? - In devexpress winforms, how can I import data into spreadsheet from a datasource? 如何将文档从Sharepoint文档库返回给用户? - How do I return a document from a Sharepoint Document library to the user? 如何获得Excel更新Excel-DNA RTD电子表格? - How can I get excel to update spreadsheet for Excel-DNA RTD?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM