简体   繁体   English

读取位于 Sharepoint 中的 excel

[英]Read excel located in Sharepoint

I already searched in Stackoverflow and found few samples using Interop.Excel.我已经在 Stackoverflow 中进行了搜索,发现使用 Interop.Excel 的示例很少。

I am using Office 2016 and Interop.Excel is targeted at 2013. I want to read an excel file located in a Sharepoint path from my C# application.我使用的是 Office 2016,Interop.Excel 面向 2013。我想从我的 C# 应用程序读取位于 Sharepoint 路径中的 excel 文件。 User will change a cell value from the application and it should get updated in the Sharepoint file.用户将从应用程序更改单元格值,它应该在 Sharepoint 文件中更新。

I checked few samples of ClosedXML but these are accessing local file and not Sharepoint.我检查了几个 ClosedXML 样本,但这些样本是访问本地文件而不是 Sharepoint。

// Starting with ClientContext, the constructor requires a URL to the
// server running SharePoint.

ClientContext context = new ClientContext("https://{site_url}");

GroupCollection siteGroups = context.Web.SiteGroups;

// Assume that there is a "Members" group, and the ID=5.
Group membersGroup = siteGroups.GetById(5);

// Let's set up the new user info.
UserCreationInformation userCreationInfo = new UserCreationInformation();
userCreationInfo.Email = "user@domain.com";
userCreationInfo.LoginName = "domain\\user";
userCreationInfo.Title = "Mr User";

// Let's add the user to the group.
User newUser = membersGroup.Users.Add(userCreationInfo);

context.ExecuteQuery();

I hope a sample code helps.我希望示例代码有所帮助。

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

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