如何解决读取位于 Sharepoint 中的 excel
我已经在 Stackoverflow 中进行了搜索,发现很少有使用 Interop.Excel 的示例。
我使用的是 Office 2016,Interop.Excel 面向 2013。我想从我的 C# 应用程序读取位于 Sharepoint 路径中的 excel 文件。用户将从应用程序中更改单元格值,它应该会在 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();
我希望示例代码有所帮助。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。