无法从SharePoint online 2013在Office客户端中打开Microsoft Office文件

Unable to open Microsoft Office files in Office client from SharePoint online 2013

本文关键字:Office 客户端 文件 Microsoft SharePoint online 2013      更新时间:2024-03-08

我们有SharePoint online 2013网站,可以显示不同部门的报告。所有部门都有不同的组,并且通过这种方式分配了权限,因此一个组无法查看其他组文件。我正在使用JAVA脚本和AJAX从库中获取文件。当我在页面上使用JavaScript时,我无法在客户端应用程序中打开文档,它在office中打开的时间比用户必须下载的要长。不管怎样,用户可以点击它,它就会下载文件。我转到库设置,将默认设置更改为在客户端应用程序中打开。网站集和功能也发生了更改,但SharePoint仍然在联机而不是客户端应用程序打开文件。我们正在使用office 2010和SharePoint online 2013。

(function () { 

    // Create object that have the context information about the field that we want to change it's output render  
    var galleryContext = {}; 
    galleryContext.Templates = {}; 

    galleryContext.Templates.Header = "<div class='gallery'>"; 
    galleryContext.Templates.Footer = "</div><div class='gallerydocs'></div>"; 

    // This line of code tell TemplateManager that we want to change all HTML for item row render 
    galleryContext.Templates.Item = galleryTemplate; 
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(galleryContext); 
})(); 
// This function provides the rendering logic 
function galleryTemplate(ctx) { 
    var icon = ctx.CurrentItem["GalleryIcon"];
    var src =  ctx.CurrentItem["FileRef"];
    var name = ctx.CurrentItem["Title"];
    var subtitle =ctx.CurrentItem["SubTitle"];
    var bgcolor = ctx.CurrentItem["BackgroundColor"];
    var fontcolor = ctx.CurrentItem["FontColor"];
    //var description = ctx.CurrentItem["Description"]; 
// console.log(JSON.stringify(ctx.CurrentItem["GalleryIcon"]));
    // Return whole item html 
    return "<div onclick='javascript:getGalleryDocs("+'"'+  src + '"' +", "+'"'+  bgcolor + '"' +", "+'"'+  subtitle + '"' +", "+'"'+  fontcolor + '"' +", "+'"'+  name + '"' +" )'><div class='galleryblock' style='background-color:" + bgcolor + ";color:"+ fontcolor+"' >"+name +"<br/><br/><p>"+subtitle +"</p></div></div>"; 
} 

function getGalleryDocs(folder , bgcolor, subtitle ,fontcolor  , name)
{
$.ajax({
        url: _spPageContextInfo.siteAbsoluteUrl + "/_api/web/GetFolderByServerRelativeUrl('"+folder+"')/files?$orderby=Title",
        method: "GET",
        headers: { "Accept": "application/json; odata=verbose" },
        success: function (data) {
        var html="<div class='gallerynav'><span><a href='javascript:goback();'>BILLING REPORTS</a><span> <i class='fa fa-caret-right' ></i><span>"+name+"</span></div><div class='galleryblock' style='float:none;background-color:" + bgcolor + ";color:"+ fontcolor+"' >"+name +"<br/><br/><p>"+subtitle +"</p></div><span></span>";
        var results = data.d.results;
        //console.log(JSON.stringify(results.length));
        html+= "<ul class='gallerylinks'>";
        if(results.length > 0)
        {
            for( i=0 ; i< results.length ; i++)
            {
                var item = results[i];
                html+= "<li><a href='" + item.LinkingUrl + "' target='_blank'>"+item.Title+"&nbsp;&nbsp;<i class='fa fa-external-link'></i></a></li>";
            }
        }
        else
        {
            html+="&nbsp;&nbsp;&nbsp;THERE ARE NO DOCUMENTS IN THIS GALLERY"
        }
        html+="<ul>"
        //console.log(JSON.stringify(data));
        $(".gallery").hide(500);
        $(".gallerydocs").html(html);
        },
        error: function (data) {
            $(".gallerydocs").html("You dont have permissions to view this folder!")
        }
        });
}
function goback(){
$(".gallery").show(500);
        $(".gallerydocs").html("");
}

我手头没有一个环境来测试它,但它将与您的href链接有关。它需要以不同的方式构建。下面的解决方案有望在客户端应用程序中打开。

尝试

    <a href=""
    onclick="editDocumentWithProgID2('http://server/site/doclib/folder/Document.docx', 
    '', 
    'SharePoint.OpenDocuments', '0', 
    'http://server/site', '0')">
    This will open the file in edit mode
</a>

完整的帖子可以在这里找到

THis post提供了一个直接下载的解决方案

对不起,我无法测试

祝好运

干杯Truez