2016-11-29 790 views
0

我有一个存储在SharePoint中的Excel文档集合。这些文件具有相同的格式(它们具有相同的纸张,每张纸具有相同的列)。现在我想从SharePoint文件夹中的每个Excel文件中导入特定工作表。PowerBI - 从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> 

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

亲切的问候,彼得 Rundqvist

回答

0

我不知道您发送的重视您的功能,但我想它运行一步一步,我想你已经误解了函数所期待的论点。 FolderPath需要进行修整你的第一个行

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

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

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

FolderPath这里是通过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

相关问题