SharePoint.Files

Sintaksis

SharePoint.Files(url as text, optional options as nullable record) as table

Tentang

Mengembalikan tabel yang berisi satu baris untuk setiap file yang ditemukan di situs SharePoint yang ditentukan, url, termasuk file dalam subfolder. Tidak seperti SharePoint.Contents, fungsi ini mengembalikan tabel datar dan tidak menyertakan baris untuk folder. URL situs tidak boleh berisi string atau fragmen kueri. Setiap baris berisi konten biner file di Content kolom dan metadata file di Namekolom , , Extension, Date accessedDate modified, Date created, Attributes, dan Folder Path . Nilainya Folder Path adalah URL absolut folder yang berisi file. options dapat ditentukan untuk mengontrol opsi berikut:

  • ApiVersion: Angka (14 atau 15) atau teks "Otomatis" yang menentukan versi API SharePoint yang akan digunakan untuk situs ini. Ketika tidak ditentukan, API versi 14 digunakan. Jika Auto ditentukan, versi server akan secara otomatis ditemukan jika memungkinkan; jika tidak, versi secara default menjadi 14. Situs SharePoint non-Bahasa Inggris memerlukan setidaknya versi 15.

Contoh 1

Cantumkan nama, ekstensi file, dan URL folder untuk setiap file di situs contoso SharePoint menggunakan pemilihan API otomatis.

Penggunaan

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.

Contoh 2

Kembalikan setiap file dengan .xlsx ekstensi dari situs contoso SharePoint. Contoh ini menggunakan API versi 15, yang berfungsi dengan situs SharePoint bahasa Inggris dan non-Bahasa Inggris. Perbandingan ekstensi tidak peka huruf besar/kecil, sehingga juga cocok .XLSXdengan .

Penggunaan

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.

Contoh 3

Mengembalikan hanya file yang disimpan langsung di Shared Documents/Reports folder. Kecocokan yang tepat Folder Path mengecualikan file dalam subfolder.

Penggunaan

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.

Contoh 4

Mengembalikan konten biner Budget.xlsx dari folder Dokumen/Laporan Bersama.

Penggunaan

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.