PowerBI - 从SharePoint文件夹中的多个Excel文件导入特定工作表

时间:2016-11-29 08:46:36

标签: powerbi

我有一组存储在SharePoint中的Excel文档。文档具有相同的格式(它们具有相同的页面,每个页面具有相同的列)。现在,我想从SharePoint文件夹中的每个Excel文件导入特定工作表。

我创建了一个函数:

   let GetExcel  = (FileName, FolderPath) =>
    let
        Source = SharePoint.Files(FolderPath, [ApiVersion = 15]),
        TheFile = Source{[Name=FileName,#"Folder Path"=FolderPath]}[Content],
        #"Imported Excel" = Excel.Workbook(TheFile),
        #"Särskilt boende_Sheet" = #"Imported Excel"{[Item="Särskilt boende",Kind="Sheet"]}[Data],
        #"Promoted Headers" = Table.PromoteHeaders(#"Särskilt boende_Sheet")
    in
        #"Promoted Headers"
    in GetExcel

我添加了一个自定义列,如下所示:

= Table.AddColumn(Source, "Custom", each GetExcel([Name], [Folder Path]))

当我尝试加载报告时,出现以下错误:

    An error occurred in the ‘GetExcel’ query. DataSource.Error:
 Microsoft.Mashup.Engine1.Library.Resources.HttpResource: Request failed: 
    OData Version: 3 and 4, Error: The remote server returned an error: (404) Not Found. (Not Found)
    OData Version: 4, Error: The remote server returned an error: (404) Not Found. (Not Found)
    OData Version: 3, Error: The remote server returned an error: (404) Not Found. (Not Found)
    Details:
        DataSourceKind=SharePoint
        DataSourcePath=<Here is a path to our shared folder in SharePoint>

我试图找出我做错了什么,但我无法理解这一点。你对我做错了什么有任何想法,请帮助:)。

亲切的问候, Peter Rundqvist

1 个答案:

答案 0 :(得分:0)

我不确定您发送功能的价值是什么,但我尝试逐步运行它,我认为您误解了功能所期望的参数。需要为第一行修剪FolderPath

Source = SharePoint.Files(FolderPath, [ApiVersion = 15])

FolderPath这里应该是托管您想要的文件的sharepoint站点或子站点的根。 SharePoint.Files返回网站上所有文件的表格。

TheFile = Source{[Name=FileName,#"Folder Path"=FolderPath]}[Content]

FolderPath这是&#39;路径&#39;通过sharepoint文件夹到文件,格式化为url。

他们应该一起看起来像这样。

Source = SharePoint.Files("https://tenantname.sharepoint.com/sites/thesite", [ApiVersion = 15]),
TheFile = Source{[Name="Workbook.xlsx",#"Folder Path"="https://tenantname.sharepoint.com/sites/thesite/Reports/2016/November/Finance Committee/"]}[Content]
祝你好运!

d