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

使用 Power BI 的“发布到 Web”选项,可在任何设备上通过电子邮件或社交媒体,轻松地将交互式 Power BI 可视化效果在线嵌入博客帖子、网站等处 。With Power BI's Publish to web option, you can easily embed interactive Power BI visualizations online, such as in blog posts, websites, through emails or social media, from any device. 还可以方便地编辑、更新、刷新或取消共享已发布的视觉对象。You can also easily edit, update, refresh, or unshare your published visuals.

警告

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

备注

要将内容安全地嵌入内部门户或网站,请使用嵌入在 SharePoint Online 中嵌入选项。To embed your content securely in an internal portal or website, use the Embed or Embed in SharePoint Online options. 这可确保在用户查看内部数据时强制执行所有权限和数据安全性。This ensures all permissions and data security is enforced when your users are viewing your internal data.

如何使用发布到 WebHow to use 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.

以下短视频演示了此功能的工作方式。The following short video shows how this feature works. 然后,按以下步骤自行尝试。Then, try it yourself in the steps below.

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

  1. 打开可编辑的工作区中的报表,然后选择“文件”>“发布到 Web” 。Open a report in your workspace that you can edit and select File > Publish to web.

    PtW1

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

    PtW2

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

    PtW3

  4. 对话框显示一条链接。A dialog appears with a link. 可以将此链接发送到电子邮件、将其嵌入 iFrame 等代码,或直接粘贴到网页或博客。You can send this link in an email, embed it in code such as an iFrame, or paste it directly into a web page or blog.

    PtW4

  5. 如果之前为报表创建了嵌入代码并选择“发布到 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:

    PtW5

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

视图模式的提示和技巧Tips and tricks 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 will scale 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 your iFrame's height and width 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 fits within the iFrame's horizontal area. 仍会显示一个边框,但内容进行缩放,以便利用所有可用的水平空间。A border is still shown, but the content scales to use all the horizontal space available.

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

“发布到 Web”嵌入如下所示的代码 :A Publish to web embed code looks like the following:

PtW7

可以手动编辑宽度和高度,确保它正以所希望的方式适应正将其嵌入到的页面。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 iFrame's height 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.

    PtW8

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

    PtW9

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

    PtW10

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

    PtW11

报表更新和数据刷新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 this initial action, however, updates to reports or visuals can take approximately one hour before becoming visible to your users. 如果你需要更新以便立即可用,可以删除嵌入代码并创建一个新的代码。If you need your updates to be immediately available, you can delete the embed code and create a new one. 若要了解详细信息,请参阅本文后面工作方式部分 。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 approximately one hour 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.

自定义视觉对象Custom visuals

自定义视觉对象在发布到 Web 中受到支持。Custom visuals are supported in Publish to web. 使用“发布到 Web”时,共享你的已发布视觉对象的用户不需要启用自定义视觉对象来查看报表 。When you use Publish to web, users with whom you share your published visual do not need to enable custom visuals to view the report.

限制Limitations

“发布到 Web”支持用于 Power BI 服务中绝大部分数据源和报表,但以下内容目前不受支持或不可用于“发布到 Web” :Publish to web is supported for the vast majority of data sources and reports in the Power BI service, however, the following are not 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 shared to you directly or through an organizational content pack.
  • 你不是编辑成员的组中的报表。Reports in a group in which you are not an edit member.
  • “发布到 Web”报表中当前不支持“R”视觉对象 。"R" Visuals are not currently supported in Publish to web reports.
  • 从已发布到 Web 的报表中的视觉对象中导出数据。Exporting Data from visuals in a report, which has been published to the web.
  • ArcGIS Maps for Power BI 视觉对象。ArcGIS Maps 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. 了解有关用户拥有数据的详细信息。Learn more about user owns data.

租户设置Tenant setting

Power BI 管理员可以启用或禁用“发布到 Web”功能 。Power BI administrators can enable or disable the Publish to web feature. 还可以限制对特定组的访问,这可能会对创建嵌入代码产生影响。They can also restrict access to specific groups, which can impact your ability to create an embed code.

功能Feature 为整个组织启用Enabled for entire organization 为整个组织禁用Disabled for entire organization 特定安全组Specific security groups
报表“文件”菜单下的“发布到 Web” Publish to web under report's File menu 为所有对象启用Enabled for all 向所有对象隐藏Not visible for all 仅向已授权的用户或组显示。Only visible for authorized users or groups.
“设置”下的“管理嵌入代码” Manage embed codes under Settings 为所有对象启用Enabled for all 为所有对象启用Enabled for all 为所有对象启用。Enabled for all.

仅向已授权的用户或组显示“删除”选项。* * Delete option only for authorized users or groups.
为所有对象启用“获取代码”。* * Get codes enabled for all.
管理门户中的“嵌入代码” Embed codes within admin portal “状态”将反映以下状态之一:Status will reflect one of the following:
* 活动* Active
* 不支持* Not supported
* 已阻止* Blocked
状态将显示“已禁用” Status will display Disabled “状态”将反映以下状态之一:Status will reflect one of the following:
* 活动* Active
* 不支持* Not supported
* 已阻止* Blocked

如果未根据租户设置为某个用户授权,状态将显示为“侵权”。 If a user is not authorized based on the tenant setting, status will display as infringed.
现有的已发布报表Existing published reports 全部已启用All enabled 全部已禁用All disabled 继续向所有对象呈现报表。Reports continue to render for all.

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

“管理嵌入代码”页包括状态列 。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 data set 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 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.

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

若要报告与嵌入到网页或博客中的“发布到 Web”内容相关的问题,请使用底部栏中的“标志”图标,如下图所示 。To report a concern related to Publish to web content embedded in a website or blog, use the Flag icon in the bottom bar, as shown in the following image. 你将需要向 Microsoft 发送一封电子邮件,解释该问题。You’ll be asked to send an email to Microsoft explaining your concern. Microsoft 将基于 Power BI 服务条款评估该内容,并采取相应的措施。Microsoft will evaluate the content based on the Power BI Terms of Service and take appropriate action.

若要报告问题,请选择所见“发布到 Web”报表的底部栏中的“标志”图标 。To report a concern, select the flag icon in the bottom bar of the Publish to web report you see.

PtW12

授权和定价Licensing and Pricing

你需要成为 Microsoft Power BI 用户才能使用发布到 WebYou need to be a Microsoft Power BI user to use Publish to web. 报告的查看者无需是 Power BI 用户。Your report's viewers do not 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 ensures that thousands of concurrent users can view the report without impacting performance.

缓存持续很长时间,因此如果你更新报表定义(例如更改其视图模式)或刷新报表数据,大约需要一小时才能在用户查看的报表版本中反映更改。The cache is long-lived, so if you update the report definition (for example, if you change its View mode) or refresh the report data, it can take approximately one hour before changes are reflected in the version of the report your users view. 因此建议你提前暂存工作,并仅当你对设置满意时创建发布到 Web 嵌入代码。It is therefore recommended that you stage your work ahead of time, and create the Publish to web embed code only when you’re satisfied with the settings.

后续步骤Next steps

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