使用PNP以编程方式在Sharepoint ModernPage中创建Fileviewer Webpart

时间:2018-07-04 13:37:01

标签: sharepoint csom

我正在使用SharePoint PNP库以编程方式创建现代页面,在其中创建Fileviewer,然后将其源设置为文档库中存在的文件。

由于某种原因,我可以看到在新创建的页面内创建的fileviewer webpart,但是没有预览文档。我收到以下错误。

对不起,出了点问题 该项目不存在。可能已被其他用户删除。

我尝试设置所有属性组合。有人可以帮助我创建和设置Modernpage的Fileviewer Webpart的源文档吗?

var page = context.Web.AddClientSidePage(pageName, true);
var temp = page.AvailableClientSideComponents().ToList();
var fileWebPart = new ClientSideWebPart(temp[6]);//6 is fileviewer webpart component, will clean this later.

fileWebPart.Properties["file"] = "https://demo.sharepoint.com/sites/VFirstTeamSite/Attachments/Imagein.docx";
fileWebPart.Properties["serverRelativeUrl"] = "/sites/VFirstTeamSite/Attachments/Imagein.docx";
fileWebPart.Properties["siteId"] = "b1de2e01-0df9-4622-b0dc-ec54333d65c2";
fileWebPart.Properties["webId"] = "76914214-eea7-405f-a688-3835888de369";
fileWebPart.Properties["listId"] = "a3b574cf-bfe7-42c9-955f-3b8d2f16b72c";
fileWebPart.Properties["startPage"] = 1;
fileWebPart.Properties["wdallowinteractivity"]= true;
fileWebPart.Properties["wdhidegridlines"]= true;
fileWebPart.Properties["wdhideheaders"]= true;
fileWebPart.Properties["uniqueId"] = "3C27A419-66D0-4C36-BF24-BD6147719052";
fileWebPart.Properties["wopiurl"] = "https://demo.sharepoint.com/sites/VFirstTeamSite/_layouts/15/WopiFrame.aspx?sourcedoc={3C27A419-66D0-4C36-BF24-BD6147719052}";
fileWebPart.Properties["authorName"]= "Bert Jansen (Cloud)";
fileWebPart.Properties["chartitem"] = "";
fileWebPart.Properties["endrange"] = "";
fileWebPart.Properties["excelSettingsType"] = "";
fileWebPart.Properties["photoUrl"] = "/_layouts/15/userphoto.aspx?size=S&accountname=vr@demo.onmicrosoft.com";
fileWebPart.Properties["rangeitem"] = "";
fileWebPart.Properties["startrange"] = "";
fileWebPart.Properties["tableitem"] = "";
page.AddControl(fileWebPart);
page.Save(pageName);

0 个答案:

没有答案