在 Power BI Desktop 中使用 OneDrive for Business 链接Use OneDrive for Business links in Power BI Desktop

很多人将 Excel 工作簿存储在 OneDrive for Business 驱动器上,这在 OneDrive 中使用起来非常方便。Many people have Excel workbooks stored on their OneDrive for Business drive that would be great for use with Power BI Desktop. 通过 Power BI Desktop,你可以使用 OneDrive for Business 中存储的 Excel 文件的联机链接来创建报表和视觉对象。With Power BI Desktop, you can use online links for Excel files stored in OneDrive for Business to create reports and visuals. 你可以使用 OneDrive for Business 组帐户或 OneDrive for Business 个人帐户。You can use a OneDrive for Business group account, or your individual OneDrive for Business account.

OneDrive for Business 获取联机链接时需执行几个特定步骤。Getting an online link from OneDrive for Business does require a few specific steps. 以下各节将说明这些步骤。这些步骤允许你在组之间、不同计算机之间以及与同事之间共享文件链接。The following sections explain those steps, which let you share the file link among groups, across different machines, and with your coworkers.

  1. 使用浏览器导航到你的 OneDrive for Business 位置。Navigate to your OneDrive for Business location using a browser. 右键单击你要使用的文件,并选择在 Excel 中打开Right-click the file you want to use, and select Open in Excel.

    备注

    你的浏览器界面可能与以下图像不完全相同。Your browser interface might not look exactly like the following image. OneDrive for Business 浏览器界面中,可使用多种方法来选择要对其执行在 Excel 中打开操作的文件。There are many ways to select Open in Excel for files in your OneDrive for Business browser interface. 可使用任何允许你在 Excel 中打开文件的选项。You can use any option that allows you to open the file in Excel.

  2. Excel 中,选择文件 > 信息,然后选择保护工作簿按钮上面的链接。In Excel, select File > Info and select the link above the Protect Workbook button. 选择“将链接复制到剪贴板”(版本中可能显示“将路径复制到剪贴板”)。Select Copy link to clipboard (your version might say Copy path to clipboard).

在 Power BI Desktop 中,你可以使用刚刚复制到剪贴板的链接。In Power BI Desktop, you can use the link you just copied to the clipboard. 可执行以下步骤:Take the following steps:

  1. 在 Power BI Desktop 中,选择获取数据 > WebIn Power BI Desktop, select Get Data > Web.

  2. 将链接粘贴到从 Web 对话框(要选择“确定”)。Paste the link into the From Web dialog (do not select OK yet).

  3. 请注意链接末尾的 ?web=1 字符串。必须首先 删除 Web URL 字符串的该部分 , 然后再选择 确定 ,以便 Power BI Desktop 正确导航到你的文件。Notice the ?web=1 string at the end of the link - you must remove that portion of the Web URL string before selecting OK, in order for Power BI Desktop to properly navigate to your file.
  4. 如果 Power BI Desktop 提示你输入凭据,请选择 Windows(适用于本地 SharePoint 站点)或组织帐户(适用于 Office 365 或 OneDrive for Business 站点)。If Power BI Desktop prompts you for credentials, choose either Windows (for on-premises SharePoint sites) or Organizational Account (for Office 365 or OneDrive for Business sites).

将出现导航器窗口,供你从 Excel 工作簿中的表、工作表和范围的列表中进行选择。A Navigator window appears, allowing you to select from the list of tables, sheets, and ranges found in the Excel workbook. 在这里,你可以像使用任何其他 Excel 文件一样使用 OneDrive for Business 文件,创建报表并将其用于数据集,就如同你对任何其他数据源执行的操作那样。From there, you can use the OneDrive for Business file just like any other Excel file, and create reports and use it in datasets like you would with any other data source.

备注

若要将 OneDrive for Business 文件用作 Power BI 服务中的数据源,在已为该文件启用“服务刷新”的情况下,请务必在配置刷新设置时选择“OAuth2”作为“身份验证方法”。To use OneDrive for Business file as a data source in the Power BI service, with Service Refresh enabled for that file, make sure you select OAuth2 as the Authentication method when configuring your refresh settings. 否则,可能会在尝试连接或刷新时看到错误消息(如“ 无法更新数据源凭据 ”)。Otherwise you may encounter an error (such as Failed to update data source credentials) when you attempt to connect or to refresh. 选择“OAuth2”作为身份验证方法可修复此凭据错误。Selecting OAuth2 as the authentication method remedies that credentials error.