語法
SharePoint.Files(url as text, optional options as nullable record) as table
關於
回傳一個包含一列的資料表,對應指定 SharePoint 網站url中每個檔案,包含子資料夾中的檔案。 與 SharePoint.Contents不同,這個函式回傳的是平面表格,且不包含資料夾的列。 網站網址不能包含查詢字串或片段。 每一列在欄位中包含檔案的二進位內容Content,並在 、 Extension、 AttributesDate accessedDate modifiedDate created欄位Folder Path中包含檔案的元資料。Name 這個 Folder Path 值是包含該檔案資料夾的絕對網址。 可以指定 options 以控制下列選項:
-
ApiVersion:數字 (14 或 15) 或文字「Auto」,其指定用於此網站的 SharePoint API 版本。 若未指定,會使用 API 第 14 版。 指定為 Auto 時,如果可能,將自動檢測伺服器版本,否則版本將預設為 14。 非英文的 SharePoint 網站至少需要第 15 版。
範例 1
請使用自動 API 選擇,列出 Contoso SharePoint 網站上每個檔案的名稱、副檔名和資料夾 URL。
Usage
let
Source = SharePoint.Files(
"https://contoso.sharepoint.com/sites/Contoso",
[ApiVersion = "Auto"]
),
SelectedColumns = Table.SelectColumns(
Source,
{"Name", "Extension", "Folder Path"}
)
in
SelectedColumns
Output
A table containing the name, extension, and absolute folder URL for each file in the site and its subfolders.
範例 2
從 Contoso SharePoint 網站回傳所有副檔名的.xlsx檔案。 此範例使用 API 版本 15,該版本同時適用於英文及非英文的 SharePoint 網站。 擴展比較不區分大小寫,因此也與 相符 .XLSX。
Usage
let
Source = SharePoint.Files(
"https://contoso.sharepoint.com/sites/Contoso",
[ApiVersion = 15]
),
ExcelWorkbooks = Table.SelectRows(
Source,
each Comparer.OrdinalIgnoreCase([Extension], ".xlsx") = 0
)
in
ExcelWorkbooks
Output
A table containing every .xlsx file in the site and its subfolders.
範例 3
只回傳直接存放在資料夾裡 Shared Documents/Reports 的檔案。 完全 Folder Path 匹配的則排除子資料夾中的檔案。
Usage
let
Source = SharePoint.Files("https://contoso.sharepoint.com/sites/Contoso"),
ReportsFiles = Table.SelectRows(
Source,
each [Folder Path] = "https://contoso.sharepoint.com/sites/Contoso/Shared Documents/Reports/"
)
in
ReportsFiles
Output
A table containing only the files stored directly in the Reports folder.
範例 4
從共享文件/報告資料夾回傳 Budget.xlsx 的二進位內容。
Usage
let
Source = SharePoint.Files("https://contoso.sharepoint.com/sites/Contoso"),
Budget = Source{
[
Name = "Budget.xlsx",
#"Folder Path" = "https://contoso.sharepoint.com/sites/Contoso/Shared Documents/Reports/"
]
}[Content]
in
Budget
Output
The binary content of Budget.xlsx.