PowerBI - 从 SharePoint 文件夹中的多个 Excel 文件导入特定工作表
PowerBI - Importing specific sheets from multiple Excel files in SharePoint folder
我有一组 Excel 文档存储在 SharePoint 中。这些文档具有相同的格式(它们具有相同的 sheet 并且每个 sheet 具有相同的列)。现在我想从 SharePoint 文件夹中的每个 Excel 文件导入特定的 sheet。
我创建了一个函数:
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>
我试图找出我做错了什么,但我无法解决这个问题。你对我做错了什么有什么想法,请帮助:)
亲切的问候,
彼得·伦德维斯特
我不确定您发送给函数的值是什么,但我尝试了 运行 一步一步,我认为您误解了函数期望的参数。 FolderPath
需要为您的第一行修剪
Source = SharePoint.Files(FolderPath, [ApiVersion = 15])
FolderPath
此处应该是托管您想要的文件的共享点站点或子站点的根目录。 SharePoint.Files
returns 站点上所有文件的 table。
TheFile = Source{[Name=FileName,#"Folder Path"=FolderPath]}[Content]
FolderPath
这里是 'path' 通过共享点文件夹到文件的格式,格式类似于 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
我有一组 Excel 文档存储在 SharePoint 中。这些文档具有相同的格式(它们具有相同的 sheet 并且每个 sheet 具有相同的列)。现在我想从 SharePoint 文件夹中的每个 Excel 文件导入特定的 sheet。
我创建了一个函数:
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>
我试图找出我做错了什么,但我无法解决这个问题。你对我做错了什么有什么想法,请帮助:)
亲切的问候, 彼得·伦德维斯特
我不确定您发送给函数的值是什么,但我尝试了 运行 一步一步,我认为您误解了函数期望的参数。 FolderPath
需要为您的第一行修剪
Source = SharePoint.Files(FolderPath, [ApiVersion = 15])
FolderPath
此处应该是托管您想要的文件的共享点站点或子站点的根目录。 SharePoint.Files
returns 站点上所有文件的 table。
TheFile = Source{[Name=FileName,#"Folder Path"=FolderPath]}[Content]
FolderPath
这里是 'path' 通过共享点文件夹到文件的格式,格式类似于 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