从 Power BI 发布到 WebPublish to web from Power BI

借助 Power BI“发布到 Web”选项,可轻松地将交互式 Power BI 内容嵌入博客文章、网站、电子邮件或社交媒体中。With the Power BI Publish to web option, you can easily embed interactive Power BI content in blog posts, websites, emails, or social media. 还可以轻松编辑、更新、刷新或停止共享已发布的视觉对象。You can also easily edit, update, refresh, or stop sharing your published visuals.


使用“发布到 Web”时,Internet 上的所有人都可查看你发布的报表或视觉对象。When you use Publish to web, anyone on the Internet can view your published report or visual. 查看不需要身份验证。Viewing requires no authentication. 它包括查看报表聚合的详细级别数据。It includes viewing detail-level data that your reports aggregate. 发布报表前,请确保可以公开共享数据和可视化效果。Before publishing a report, make sure it's okay for you to share the data and visualizations publicly. 请勿发布机密或专有信息。Don't publish confidential or proprietary information. 如果有任何疑问,请在发布前查看组织策略。If in doubt, check your organization's policies before publishing.


可以将内容安全地嵌入内部门户或网站。You can embed your content securely in an internal portal or website. 使用嵌入”在 SharePoint Online 中嵌入”选项。Use the Embed or Embed in SharePoint Online options. 这些选项可确保在用户查看内部数据时强制执行所有权限和数据安全性。These options ensure that all permissions and data security are enforced when your users view your internal data.

通过“发布到 Web”创建嵌入代码Create embed codes with Publish to web

可在个人工作区或组工作区中编辑的报表提供有“发布到 Web”功能。Publish to web is available for reports you can edit in your personal and group workspaces. 但与你共享的报表,或依赖行级安全性来保护数据的报表不提供该功能。It isn't available for reports shared with you, or ones relying on row-level security to secure data. 请参阅以下限制部分,了解有关不支持“发布到 Web”的情况的完整列表 。See the Limitations section below for a complete list of cases where Publish to web isn't supported. 使用“发布到 Web”前请查看本文之前所述的“警告”部分 。Review the Warning earlier in this article before using Publish to web.

以下步骤介绍如何使用发布到 WebThe following steps describe how to use Publish to web.

  1. 打开可编辑的工作区中的报表,然后选择“更多选项 (...)” > “嵌入” > “发布到 Web (公共)”。Open a report in a workspace that you can edit, and select More options (...) > Embed > Publish to web (public).

    “更多选项”中的“发布到 Web”

  2. 如果 Power BI 管理员尚未允许你创建嵌入代码,则可能需要与他们联系。If your Power BI admin hasn't allowed you to create embed codes, you may need to contact them.

    与 Power BI 管理员联系

    若要获取在查找谁能在组织中启用“发布到 Web”方面的帮助,请参阅本文后面的如何查找 Power BI 管理员For help finding the person who can enable Publish to web in your organization, see How to find your Power BI administrator later in this article.

  3. 查看对话框内容,然后选择“创建嵌入代码”。Review the dialog content and select Create embed code.


  4. 查看如下所示的警告,并确认数据是否准备好嵌入到公共网站。Review the warning, as shown here, and confirm that the data is okay to embed in a public website. 如果已准备好,选择“发布”。If it is, select Publish.


  5. 对话框显示一条链接。A dialog appears with a link. 选择该链接以在电子邮件中发送,或复制 HTML。Select the link to send it in email, or copy the HTML. 可以将它嵌入 iFrame 等代码,或直接粘贴到网页或博客。You can embed it in code such as an iFrame, or paste it directly into a web page or blog.

    成功:链接和 HTML

  6. 如果之前为报表创建了嵌入代码并选择“发布到 Web”,则不会显示步骤 2-4 中的对话框。If you previously created an embed code for a report and you select Publish to web, you won't see the dialogs in steps 2-4. 相反,将显示“嵌入代码”对话框:Instead, the Embed code dialog appears:


    每个报表只能创建一个嵌入代码。You can only create one embed code for each report.

视图模式的提示Tips for view modes

在博客帖子中嵌入内容时,通常需要调整以适合屏幕的特定大小。When you embed content within a blog post, you typically need to fit it within a specific screen size. 可根据需要调整 iFrame 标记中的高度和宽度。You can adjust the height and the width in the iFrame tag as needed. 但需要确保报表适合给定的 iFrame 区域,因此编辑报表时还需要设置相应的视图模式。However, you need to ensure your report fits within the given iFrame area, so you also need to set an appropriate View Mode when editing the report.

下表提供有关视图模式及其嵌入时外观的指导。The following table provides guidance about the View Mode, and how it will appear when embedded.

视图模式View Mode 嵌入时外观How it looks when embedded
PtW6b “调整到页面大小”会考虑报表的页面高度和宽度。Fit to page respects your report's page height and width. 如果将页面设置为动态比率,如 16:9 或 4:3,内容将在 iFrame 范围内缩放至合适的大小。If you set your page to dynamic ratios like 16:9 or 4:3, your content scales to fit within the iFrame. 嵌入 iFrame 中时,使用“调整到页面大小”可能会导致“宽屏”,内容在 iFrame 中调整至合适大小后,iFrame 区域会显示灰色背景。When embedded in an iFrame, using Fit to page can result in letterboxing, where a gray background is shown in iFrame areas after the content is scaled to fit within the iFrame. 为了最大限度地减少上下黑边,请正确设置 iFrame 的高度和宽度。To minimize letterboxing, set the height and width of the iFrame appropriately.
PtW6d “实际大小”确保报表保持其在报表页上设置的大小。Actual size ensures the report preserves its size as set on the report page. 这可能导致 iFrame 中显示滚动条。This can result in scrollbars appearing in your iFrame. 设置 iFrame 高度和宽度,以避免出现滚动条。Set the iFrame height and width to avoid scrollbars.
PtW6c “适应宽度”确保内容填充 iFrame 的水平区域。Fit to width ensures the content fills the horizontal area of the iFrame. 仍会显示一个边框,但内容进行缩放,以便利用所有可用的水平空间。A border is still shown, but the content scales to use all the horizontal space available.

iFrame 高度和宽度的提示Tips for iFrame height and width

“发布到 Web”嵌入类似于以下示例的代码:A Publish to web embed code looks like the following example:


可以手动编辑宽度和高度,确保它正以所希望的方式适应正将其嵌入到的页面。You can edit the width and height manually to ensure it's precisely how you want it to fit in the page where you're embedding it.

若要实现更完美的适应,可尝试为 iFrame 的高度添加 56 个像素,以适应底部栏的当前大小。To achieve a more perfect fit, you can try adding 56 pixels to the height of the iFrame to accommodate the current size of the bottom bar. 如果报表页使用动态尺寸,下表提供了一些可用于实现适应页面而不会造成宽屏的尺寸。If your report page uses the dynamic size, the table below provides some sizes you can use to achieve a fit without letterboxing.

比率Ratio 大小Size 尺寸(宽 x 高)Dimension (width x height)
16:916:9 Small 640 x 416 px640 x 416 px
16:916:9 Medium 800 x 506 px800 x 506 px
16:916:9 Large 960 x 596 px960 x 596 px
4:34:3 Small 640 x 536 px640 x 536 px
4:34:3 Medium 800 x 656 px800 x 656 px
4:34:3 Large 960 x 776 px960 x 776 px

管理嵌入代码Manage embed codes

创建“发布到 Web”嵌入代码后,可通过 Power BI 中的“设置”菜单管理代码 。Once you create a Publish to web embed code, you can manage your codes from the Settings menu in Power BI. 管理嵌入代码包括,能够删除代码的目标视觉对象或报表(使嵌入代码不可用),或获取嵌入代码。Managing embed codes includes the ability to remove the destination visual or report for a code (rendering the embed code unusable), or getting the embed code.

  1. 若要管理你的发布到 Web 嵌入代码,打开设置齿轮,然后选择管理嵌入代码To manage your Publish to web embed codes, open the Settings gear and select Manage embed codes.


  2. 显示嵌入代码。Your embed codes appear.


  3. 可以检索,也可以删除嵌入代码。You can either retrieve or delete an embed code. 删除它会禁用指向该报表或视觉对象的任何链接。Deleting it disables any links to that report or visual.


  4. 如果选择“删除”,系统会提示进行确认。If you select Delete, you're asked for a confirmation.


报表更新和数据刷新Updates to reports, and data refresh

创建“发布到 Web”嵌入代码并将其共享后,将使用你所做的所有更改对报表进行更新,并立即激活嵌入代码链接。After you create your Publish to web embed code and share it, the report is updated with any changes you make, and the embed code link is immediately active. 打开链接的任何人都可以查看。Anyone who opens the link can view it. 初始创建后,对报表或视觉对象的更新可能需要两个小时用户才能看到它们。After the initial creation, updates to reports or visuals may take up to two hours before your users see them. 数据将缓存一小时(从检索时间开始)。The data is cached for one hour from the time it is retrieved. 对于需要频繁刷新的数据,不建议使用“发布到 Web”。We don’t recommend using Publish to web for data that needs to refresh frequently. 若要了解详细信息,请参阅本文后面工作方式部分。To learn more, see the How it works section later in this article.

数据刷新Data refresh

数据刷新自动反映在嵌入的报表或视觉对象中。Data refreshes are automatically reflected in your embedded report or visual. 从嵌入代码中看到刷新的数据可能需要两小时。It can take up to two hours for refreshed data to be visible from embed codes. 若要禁用自动刷新,选择报表所用数据集计划上的“不刷新”。To disable automatic refresh, select don't refresh on the schedule for the dataset the report uses.

Power BI 视觉对象Power BI visuals

在“发布到 Web 中”,支持 Power BI 视觉对象。Power BI visuals are supported in Publish to web. 使用“发布到 Web”时,共享你的已发布视觉对象的用户不需要启用 Power BI 视觉对象即可查看报表。When you use Publish to web, users with whom you share your published visual don't need to enable Power BI visuals to view the report.

了解嵌入代码状态列Understanding the embed code status column


查看经常发布的嵌入代码。Review the embed codes you've published often. 删除不再需要公开提供的任何代码。Remove any that no longer need to be available publicly.

“管理嵌入代码”页包括状态列。The Manage embed codes page includes a status column. 嵌入代码默认处于“激活”状态,但也可能处于以下状态之一。By default, embed codes are Active, but could also be one of the statuses listed below.

状态Status 说明Description
活动Active 该报表可供 Internet 用户查看并进行交互。The report is available for Internet users to view and interact with.
被阻止Blocked 报表内容违反了 Power BI 服务条款The report content violates the Power BI Terms of Service. Microsoft 已将其阻止。Microsoft has blocked it. 如果你认为内容被错误阻止,请与支持部门联系。Contact support if you believe the content was blocked in error.
不支持Not supported 报表的数据集正在使用行级别安全性或另一个不受支持的配置。The report's dataset is using row-level security, or another unsupported configuration. 请参阅限制部分中的完整列表。See the Limitations section for a complete list.
侵权Infringed 嵌入代码在定义的租户策略外部。The embed code is outside the defined tenant policy. 如果在创建嵌入代码后更改“发布到 Web”租户设置以排除拥有该嵌入代码的用户,则通常会出现此状态。This status typically occurs when an embed code was created and then the Publish to web tenant setting was changed to exclude the user owning the embed code. 如果已禁用租户设置,或者不再允许用户创建嵌入代码,则现有嵌入代码显示“侵权”状态。If the tenant setting is disabled, or the user is no longer allowed to create embed codes, existing embed codes show an Infringed status. 有关详细信息,请参阅本文中的查找 Power BI 管理员部分。See the Find your Power BI administrator section in this article for details.

报告有关发布到 Web 内容的问题Report a concern with Publish to web content

若要报告与嵌入到网页或博客中的“发布到 Web”内容相关的问题,请使用“发布到 Web”报表底部栏中的“标志”图标。To report a concern related to Publish to web content embedded in a website or blog, select the Flag icon in the bottom bar of the Publish to web report.


你需要向 Microsoft 发送一封电子邮件,解释该问题。You're asked to send an email to Microsoft explaining your concern. Microsoft 会基于 Power BI 服务条款评估该内容,并采取相应的措施。Microsoft evaluates the content based on the Power BI Terms of Service and takes appropriate action.


你需要成为 Microsoft Power BI 用户才能使用发布到 WebYou need to be a Microsoft Power BI user to use Publish to web. 报告查看者无需是 Power BI 用户。Your report viewers don't need to be Power BI users.

工作方式(技术详细信息)How it works (technical details)

使用“发布到 Web”创建嵌入代码时,报表对所有 Internet 用户均可见。When you create an embed code using Publish to web, the report is made visible to Internet users. 它是公开提供的,因此你可以期望将来查看者能够轻松地通过社交媒体共享报表。It's publicly available, so you can expect viewers to easily share the report through social media in the future. 用户查看报表,或者通过打开直接公共 URL,或者在嵌入到的网页或博客中查看,Power BI 将缓存报表定义和查看报表所需的查询结果。As users view the report, either by opening the direct public URL or viewing it embedded in a web page or blog, Power BI caches the report definition and the results of the queries required to view the report. 此缓存可确保成千上万的并发用户能够在不影响性能的情况下查看报表。This caching ensures that thousands of concurrent users can view the report without impacting performance.

数据将缓存一小时(从检索时间开始)。The data is cached for one hour from the time it is retrieved. 如果你更新报表定义(例如更改其视图模式)或刷新报表数据,可能需要两小时才能在用户查看的报表版本中反映更改。If you update the report definition (for example, if you change its View mode) or refresh the report data, it can take up to two hours before changes are reflected in the version of the report that your users view. 由于每个元素和数据值都是独立缓存的,因此当发生数据更新时,可以向用户显示当前值和以前值的组合。Since each element and data value is cached independently, when a data update occurs a mix of current and previous values can be shown to a user. 因此建议你提前暂存工作,并仅在对设置满意时创建“发布到 Web”嵌入代码。Therefore, we recommend staging your work ahead of time, and creating the Publish to web embed code only when you're satisfied with the settings. 如果数据会刷新,则最大限度地减少刷新次数,并在关闭时执行刷新。If your data will refresh, minimize the number of refreshes and perform the refreshes at off hours. 对于需要频繁刷新的数据,不建议使用“发布到 Web”。We don’t recommend using Publish to web for data that needs to refresh frequently.

查找 Power BI 管理员Find your Power BI administrator

Power BI 管理门户具有控制可以发布到 Web 的人员的设置。The Power BI admin portal has settings that control who can publish to the web. 与组织的 Power BI 管理员合作,在管理门户中更改“发布到 Web”租户设置Work with your organization's Power BI administrator to change the Publish to web tenant settings in the admin portal.

对于已注册 Power BI 的小型组织或个人,可能还没有 Power BI 管理员。For smaller organizations or individuals who signed up for Power BI, you may not have a Power BI administrator yet. 遵循管理员接管流程Follow our process for admin takeover. 有了 Power BI 管理员后,他们就可以为你创建嵌入代码。Once you have a Power BI administrator, they can enable creating embed codes for you.

已建立的组织通常已有 Power BI 管理员。Established organizations usually already have a Power BI administrator. 担任以下任何角色的人员都可以充当 Power BI 管理员:People in any of the following roles can act as a Power BI administrator:

  • 全局管理员Global administrators
  • 在 Azure Active Directory 中具有 Power BI 服务管理员角色的用户Users with the Power BI service admin role in Azure Active Directory

需要在组织中找到这些人中的一个,请他们在管理门户中更新“发布到 Web”租户设置You need to find one of these people in your organization and ask them to update the Publish to web tenant settings in the admin portal.


“发布到 Web”支持用于 Power BI 服务中绝大部分数据源和报表。Publish to web is supported for the vast majority of data sources and reports in the Power BI service. 但以下类型的报表当前不受支持或不可用于“发布到 Web”:However, the following kinds of reports aren't currently supported or available with Publish to web:

  • 使用行级别安全性的报表。Reports using row-level security.
  • 使用任何实时连接数据源的报表,包括在本地托管的 Analysis Services 表格、Analysis Services Multidimensional 以及 Azure Analysis Services。Reports using any Live Connection data source, including Analysis Services Tabular hosted on-premises, Analysis Services Multidimensional, and Azure Analysis Services.
  • 使用共享数据集的报表,共享数据集与报表存储在不同的工作区中。Reports using a shared dataset that is stored in a different workspace from the report.
  • 共享和经认证的数据集Shared and certified datasets.
  • 直接或通过组织内容包共享的报表。Reports shared to you directly or through an organizational content pack.
  • 你不是编辑成员的工作区中的报表。Reports in a workspace in which you aren't an edit member.
  • “发布到 Web”报表中当前不支持“R”和 Python 视觉对象。"R" and Python visuals aren't currently supported in Publish to web reports.
  • 从已发布到 Web 的报表中的视觉对象中导出数据。Exporting data from visuals in a report that has been published to the web.
  • ArcGIS Maps for Power BI 视觉对象。ArcGIS Maps for Power BI visuals.
  • 有关 Power BI 视觉对象的问答。Q&A for Power BI visuals.
  • 包含报表级别 DAX 度量值的报表。Reports containing report-level DAX measures.
  • 单一登录数据查询模型。Single sign-on data query models.
  • 保护机密或专有信息。Secure confidential or proprietary information.
  • 随“嵌入”选项提供的自动身份验证功能不适用于 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 approach to embedding.

后续步骤Next steps

更多问题?More questions? 尝试参与 Power BI 社区Try the Power BI Community