在安全门户或网站中嵌入报表Embed a report in a secure portal or website

借助 Power BI 报表的新“嵌入”选项,你可以轻松、安全地在内部 Web 门户中嵌入报表。With the new Embed option for Power BI reports, you can easily and securely embed reports in internal web portals. 这些门户可以是基于云的,也可以是本地托管的,例如 SharePoint 2019 。These portals can be cloud-based or hosted on-premises, such as SharePoint 2019. 嵌入的报表通过行级别安全性 (RLS) 尊重所有项目权限和数据安全性。Embedded reports respect all item permissions and data security through row-level security (RLS). 它们在任何接受 URL 或 iFrame 的门户中提供无代码嵌入。They provide no-code embedding into any portal that accepts a URL or iFrame.

“嵌入”选项支持 URL 筛选器和 URL 设置。The Embed option supports URL filters and URL settings. 它使你可以使用只需要基本 HTML 和 JavaScript 知识的低代码方法来与门户集成。It allows you to integrate with portals using a low-code approach requiring only basic HTML and JavaScript knowledge.

如何将 Power BI 报表嵌入门户How to embed Power BI reports into portals

  1. 在 Power BI 服务中打开报表。Open a report in the Power BI service.

  2. 在“更多选项(...)”菜单中,选择“嵌入” > “网站或门户”。On the More options (...) menu, select Embed > Website or portal.

    网站或门户选项

  3. 选择“嵌入”选项将打开一个对话框,该对话框提供一个链接和一个可用于安全嵌入报表的 iFrame。Select the Embed option to open a dialog that provides a link and an iFrame you can use to embed the report securely.

    “嵌入”选项对话框

  4. 无论用户是直接打开报表 URL,还是打开嵌入在 Web 门户中的报表 URL,都需要进行身份验证才能访问报表。Whether a user opens a report URL directly, or one embedded in a web portal, report access requires authentication. 如果用户未在其浏览器会话中登录 Power BI,将会显示以下屏幕。The following screen appears if a user has not signed-in to Power BI in their browser session. 当用户选择“登录”时,可能会打开新的浏览器窗口或标签页。When they select Sign-In, a new browser window or tab could open. 如果未提示用户进行登录,请让他们检查是否启用了弹出窗口阻止程序。Have them check for pop-up blockers if they don't get prompted to sign in.

    登录以查看此报表

  5. 用户登录后,将打开报表,其中显示了数据并允许进行页面导航和筛选器设置。After the user has signed in, the report opens, showing the data and allowing page navigation and filter setting. 只有拥有查看权限的用户才能在 Power BI 中查看报表。Only users who have view permission can see the report in Power BI. 此外,还应用了所有行级别安全性 (RLS) 规则。All row-level security (RLS) rules are also applied. 最后,用户需要获得正确许可,要么需要 Power BI Pro 许可证,要么报表必须位于处于 Power BI Premium 容量范围内的工作区中。Lastly, the user needs to be correctly licensed – either they need a Power BI Pro license, or the report must be in a workspace that is in a Power BI Premium capacity. 用户每次打开新的浏览器窗口时都需要登录。The user needs to sign in each time they open a new browser window. 不过,登录后,其他报表会自动加载。However, once signed in, other reports load automatically.

    嵌入报表

  6. 使用 iFrame 时,可能需要编辑“高度”和“宽度”,以使其适合门户的网页 。When using an iFrame, you may need to edit the height and width to have it fit in your portal's web page.

    设置高度和宽度

授予报表访问权限Granting report access

“嵌入”选项不会自动允许用户查看报表。The Embed option doesn't automatically permit users to view the report. 查看权限在 Power BI 服务中设置。View permissions are set in the Power BI service.

在 Power BI 服务中,你可以与需要访问权限的用户共享嵌入的报表。In the Power BI service, you can share embedded reports with users requiring access. 如果使用 Microsoft 365 组,你可以将该用户列为工作区成员。If you're using a Microsoft 365 Group, you can list the user as a workspace member. 有关详细信息,请参阅如何管理 Power BI 和 Microsoft 365 中的工作区For more information, see how to manage your workspace in Power BI and Microsoft 365.

许可Licensing

要查看嵌入的报表,用户需要具有 Power BI Pro 许可证,或该内容需要位于处于 Power BI Premium 容量(EM 或 P SKU)范围内的工作区中。To view the embedded report, users need either a Power BI Pro license or the content needs to be in a workspace that's in a Power BI Premium capacity (EM or P SKU).

使用 URL 设置自定义嵌入体验Customize your embed experience using URL settings

你可以使用嵌入 URL 的输入设置来自定义用户体验。You can customize the user experience using the embed URL's input settings. 在提供的 iFrame 中,可以更新 URL 的 src 设置。In the provided iFrame, you can update the URL's src settings.

属性Property 说明Description
pageNamepageName 你可以使用 pageName 查询字符串参数来设置要打开的报表页面。You can use the pageName query string parameter to set which report page to open. 在 Power BI 服务中查看报表时,你可以在报表 URL 的末尾找到此值,如下所示。You can find this value at the report URL's end when viewing a report in the Power BI service, as shown below.
URL 筛选器URL Filters 你可以在从 Power BI UI 接收到的嵌入 URL 中使用 URL 筛选器来筛选嵌入的内容。You can use URL Filters in the embed URL you received from the Power BI UI to filter the embed content. 借助这种方式,可以通过基本 HTML 和 JavaScript 体验生成低代码集成。This way you can build low-code integrations with only basic HTML and JavaScript experience.

为嵌入的报表设置要打开的页面Set which page opens for an embedded report

在 Power BI 服务中查看报表时,你可以在报表 URL 处找到 pageName 值。You can find the pageName value at the report URL's end when viewing a report in the Power BI service.

  1. 从 Web 浏览器中的 Power BI 服务打开报表,然后复制地址栏中的 URL。Open the report from the Power BI service in your web browser, and then copy the address bar URL.

    报表区域

  2. 将 pageName 设置追加到此 URL。Append the pageName setting to the URL.

    追加 pageName

使用 URL 筛选器筛选报表内容Filter report content using URL filters

你可以使用 URL 筛选器来提供不同的报表视图。You can use URL Filters to provide different report views. 例如,下面的 URL 筛选报表以显示能源行业的数据。For example, the URL below filters the report to show data for the Energy industry.

将 pageName 和 URL 筛选器结合使用的功能非常强大。Using the combination of pageName and URL Filters can be powerful. 可以使用基本 HTML 和 JavaScript 生成体验。You can build experiences using basic HTML and JavaScript.

例如,可以将以下按钮添加到 HTML 页面:For example, here's a button you can add to an HTML page:

<button class="textLarge" onclick='show("ReportSection", "Energy");' style="display: inline-block;">Show Energy</button>

选择此按钮时,此按钮会调用一个函数,以使用更新的 URL 来更新 iFrame,其中包含能源行业筛选器。When selected, the button calls a function to update the iFrame with an updated URL, which includes the Energy industry filter.

function show(pageName, filterValue)

{

var newUrl = baseUrl + "&pageName=" + pageName;

if(null != filterValue && "" != filterValue)

{

newUrl += "&$filter=Industries/Industry eq '" + filterValue + "'";

}

//Assumes there's an iFrame on the page with id="iFrame"

var report = document.getElementById("iFrame")

report.src = newUrl;

}

筛选

可以根据需要添加任意数量的按钮,以创建低代码自定义体验。You can add as many buttons as you'd like to create a low-code custom experience.

注意事项和限制Considerations and limitations

  • 安全嵌入方案支持分页报表,并且还支持带有 URL 参数的分页报表。Paginated reports are supported with secure embed scenarios, and paginated reports with URL parameters are also supported. 阅读有关在分页报表的 URL 中传递报表参数的详细信息。Read more about passing report parameters in a URL for a paginated report.

  • 安全嵌入适用于发布到 Power BI 服务的报表。Secure embed works for reports published to the Power BI service.

  • 用户每次打开新的浏览器窗口时都需要登录才能查看报表。The user needs to sign in to view the report whenever they open a new browser window.

  • 某些浏览器要求用户在登录后刷新页面,尤其是在使用 InPrivate 或 Incognito 模式的情况下。Some browsers require you to refresh the page after sign-in, especially when using InPrivate or Incognito modes.

  • 如果使用不受支持的浏览器版本,则可能会遇到问题。You may encounter issues if using unsupported browser versions. Power BI 支持以下浏览器列表Power BI supports the following list of browsers.

  • 经典 SharePoint Server 不受支持,因为它需要 11 之前的 Internet Explorer 版本或启用“兼容性视图”模式。The classic SharePoint Server isn't supported, as it requires Internet Explorer versions earlier than 11, or enabling the compatibility view mode.

  • 要实现单一登录体验,请使用“在 SharePoint Online 中嵌入”选项,或使用用户拥有数据嵌入方法生成自定义集成。To achieve a single sign-on experience, use the Embed in SharePoint Online option, or build a custom integration using the user owns data embedding method.

  • 随“嵌入”选项提供的自动身份验证功能不适用于 Power BI JavaScript API。The automatic authentication capability provided with the Embed option doesn't work with the Power BI JavaScript API. 对于 Power BI JavaScript API,请使用用户拥有数据嵌入方法。For the Power BI JavaScript API, use the user owns data embedding method.

  • 身份验证令牌生存期基于 AAD 设置进行控制。The authentication token lifetime is controlled based on your AAD settings. 当身份验证令牌过期时,用户需要刷新其浏览器以获取更新的身份验证令牌。When the authentication token expires, the user will need to refresh their browser to get an updated authentication token. 默认生存期为一小时,但你的组织可能设置更短或更长的时间。The default lifetime is one hour, but it could be shorter or longer in your organization. 在这种情况下,无法自动刷新令牌。There is no ability to automatically refresh the token in this scenario.

后续步骤Next steps