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

借助 Power BI 发布到 Web,可在任何设备上通过电子邮件或社交媒体,轻松地将交互式 Power BI 可视化效果在线嵌入博客帖子、网站等处。With Power BI Publish to web, you can easily embed interactive Power BI visualizations online, such as in blog posts, websites, through emails or social media, on any device.

可以方便地编辑、更新、刷新或取消共享已发布的视觉对象。You can also easily edit, update, refresh or un-share your published visuals.

警告

当使用“发布到 Web”时,发布的报表或视觉对象可被 Internet 上的所有人查看。When you use Publish to web, the report or visual you publish can be viewed by anyone on the Internet. 查看这些报表时没有使用身份验证。There is no authentication used when viewing these reports. 仅对可供 Internet 上所有人(未经身份验证的公共成员)查看的报表和数据使用“发布到 Web”。Only use Publish to web with reports and data that the anyone on the Internet (unauthenticated members of the public) should be able to see. 这包括在报表中聚合的详细级别数据。This includes detail level data that is aggregated in your reports. 在发布此报表前,请确保你有权公开共享此数据和视觉对象。Before publishing this report, ensure you have the right to share the data and visualizations publicly. 请勿发布机密或专有信息。Do not publish confidential or proprietary information. 如果有任何疑问,请在发布前查看组织策略。If in doubt, check your organization's policies before publishing.

如何使用发布到 WebHow to use Publish to Web

可编辑的个人或组工作区中的报表上提供“发布到 Web” 功能。Publish to web is available on reports in your personal or group workspaces that you can edit. 无法对与你共享的报表或依赖于行级别安全性来保护数据的报表使用“发布到 Web”。You cannot use Publish to web with reports that were shared with you, or reports that rely on row level security to secure the data. 请参阅以下“限制”部分有关不支持“发布到 Web”的案例的完整列表。See the Limitations section below for a complete list of cases where Publish to web is not supported. 使用“发布到 Web”前请查看本文之前所述的警告部分。Please review the Warning earlier in this article before using Publish to web.

可在下面简短视频中观看此功能的工作方式。You can watch how this feature works in the following short video. 然后,按照以下步骤亲自尝试。Then, follow the steps below to try it yourself.

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

  1. 在可编辑的工作区中的报表上,选择文件 > 发布到 WebOn a report in your workspace that you can edit, select File > Publish to web.

  2. 查看对话框上的内容,然后选择创建嵌入代码,如以下对话框中所示。Review the content on the dialog, and select Create embed code as shown in the following dialog.

  3. 查看显示在以下对话框中的警告,并确认数据是否准备好嵌入到公共网站。Review the warning, shown in the following dialog, and confirm that the data is okay to embed in a public website. 如果是这样,则选择发布If so, select Publish.

  4. 将出现一个对话框,提供一个可通过电子邮件发送、嵌入在代码(如 iFrame)中的链接,或者你可以直接粘贴到网页或博客中的链接。A dialog appears that provides a link that can be sent in email, embedded in code (such as an iFrame), or that you can paste directly into your web page or blog.

  5. 如果之前已创建报表的嵌入代码,则将快速显示嵌入代码。If you’ve previously created an embed code for the report, the embed code quickly appears. 每个报表只能创建一个嵌入代码。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 size of the screen. 还可根据需要调整 iFrame 标记中的高度和宽度,但可能还需要确保报表适合 iFrame 给定区域,因此还需在编辑报表时设置适当的视图模式。You can also adjust the height and the width in the iFrame tag as needed, but you may also need to ensure your report fits within the given area of the iFrame, 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
适应页面将考虑报表的页面高度和宽度。Fit to page will respect the page height and width of your report. 如果你将页面设置为“动态”比率,如 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 you provided. 当嵌入在 iFrame 中时,使用“适应页面”可能会导致“宽屏”,内容在 iFrame 中调整至合适大小后,灰色背景会显示在 iFrame 的区域中。When embedded in an iFrame, using Fit to page can result in letterboxing, where a gray background is shown in areas of the iFrame after the content as scaled to fit within the iFrame. 为了尽量减少宽屏幕,请正确设置 iFrame 的高度/宽度。To minimize letterboxing, set your iFrame height/width appropriately.
实际大小将确保报表保持其在报表页上设置的大小。Actual size will ensure the report preserves its size as set on the report page. 这可能导致 iFrame 中显示滚动条。This can result in scrollbars being present in your iFrame. 设置 iFrame 高度和宽度,以避免滚动条。Set the iFrame height and width to avoid the scrollbars.
适应宽度可确保内容适合 iFrame 的水平区域。Fit to width ensures the content fits within the horizontal area for your iFrame. 仍会显示一个边框,但内容进行缩放,以便利用所有可用的水平空间。A border will still be shown, but the content will scale to use all the horizontal space available.

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

发布到 Web 后你收到的嵌入代码将如下所示:The embed code you receive after you Publish to web will look like the following:

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

若要实现更多最佳选择,你可以尝试向 iFrame 的高度维度添加 56 像素。To achieve a more perfect fit, you can try adding 56 pixels to the height dimension of the iFrame. 这将调整底部栏的当前大小。This accomodates 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

管理嵌入代码Managing embed codes

一旦创建发布到 Web 嵌入代码,即可从 Power BI 服务的设置菜单管理创建的代码。Once you create a Publish to web embed code, you can manage the codes you create from the Settings menu of the Power BI service. 管理嵌入代码包括,能够删除代码的目标视觉对象或报表(使嵌入代码不可用),或再次获取嵌入代码。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 again.

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

  2. 将显示已创建的嵌入代码的列表,如下图所示。The list of embed codes you’ve created appears, as shown in the following image.

  3. 对于列表中每个发布到 Web 嵌入代码,你可以检索嵌入代码,或删除嵌入代码,因此使得指向该报表或视觉对象的任何链接不再起作用。For each Publish to web embed code in the list, you can either retrieve the embed code, or delete the embed code and thus make any links to that report or visual no longer work.

  4. 如果你选择“删除”,系统会询问你是否确实要删除嵌入代码。If you select Delete, you’re asked if you’re sure you want to delete the embed code.

报表更新和数据刷新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. 但是,务必要了解你的用户可能需要一段时间才能看到更新。However, it’s important to know that it can take a while for update to be visible to your users. 报表或视觉对象更新大约需要一小时才会反映在发布到 Web 嵌入代码中。Updates to a report or visual take approximately one hour to be reflected in Publish to web embed codes.

当你最初使用发布到 Web 获取嵌入代码时,嵌入代码链接立即处于活动状态,且任何打开该链接的人均可查看。When you initially use Publish to web to get an embed code, the embed code link is immediately active and can be viewed by anyone who opens the link. 在初始发布到 Web 操作后,发布到 Web 链接指向的报表或视觉对象的更新大约需要一小时才可供你的用户查看。After the initial Publish to web action, subsequent updates to reports or visuals to which a Publish to web link points can take approximately one hour to be visible to your users.

若要了解详细信息,请参阅本文后面工作方式部分。To learn more, see the How it works section later in this article. 如果你需要更新以便立即可用,可以删除嵌入代码并创建一个新的代码。If you need your updates to be immediately available, you can delete the embed code and create a new one.

数据刷新Data refresh

数据刷新自动反映在嵌入的报表或视觉对象中。Data refreshes are automatically reflected in your embedded report or visual. 大约需要 1 小时才可从嵌入代码中看到刷新的数据。It can take approximately 1 hour for refreshed data to be visible from embed codes. 选择报表所用数据集计划上的不刷新可以禁用自动刷新。You can disable automatic refresh by selecting do not refresh on the schedule for the dataset used by the report.

自定义视觉对象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:

  1. 使用行级别安全性的报表。Reports using row level security.
  2. 使用在本地托管的 Analysis Services 表的报表。Reports using Analysis Services Tablular hosted on premises.
  3. 直接或通过组织内容包共享的报表。Reports shared to you directly or through an organizational content pack.
  4. 你不是编辑成员的组中的报表。Reports in a group in which you are not an edit member.
  5. “发布到 Web”报表中当前不支持“R”视觉对象。"R" Visuals are not currently supported in Publish to web reports.

租户设置Tenant setting

Power BI 管理员可以启用或禁用“发布到 Web”功能。Power BI administrators can enable or disable the publish to web feature. 他们还可以限制对特定组的访问。They may also restrict access to specific groups. 可以基于此设置创建嵌入代码更改。Your ability to create an embed code changes based on this setting.

功能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 visable for all 仅向已授权的用户或组显示。Only visable 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

当查看你的发布到 Web 嵌入代码的管理嵌入代码 页时,将提供一个状态列。When viewing the Manage embed codes page for your Publish to web embed codes, a status column is provided. 默认情况下,嵌入代码处于活动状态,但是你可能会遇到下面列出的状态。Embed codes are active by default, but you may encounter any of the states listed below.

状态Status 说明Description
活动Active 该报表可供 Internet 用户查看并进行交互。The report is available for Internet users to view and interact with.
被阻止Blocked 报表的内容违反了 Power BI 服务条款The content of the report violates the Power BI Terms of Service. 它已被 Microsoft 阻止。It has been blocked by Microsoft. 如果你认为内容被错误阻止,请与支持部门联系。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 of 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 that owns the embed code. 如果租户设置已禁用,或者不再允许用户创建嵌入代码,则现有嵌入代码将显示“侵权”状态。If the tenant setting is disabled, or the user is no longer allowed to create embed codes, existing embed codes will show the status of Infringed.

如何报告有关发布到 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, shown in the following image. 你将需要向 Microsoft 发送一封电子邮件,解释该问题。You’ll be asked to send an email to Microsoft explaining the 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.

授权和定价Licensing and Pricing

你需要成为 Microsoft Power BI 用户才能使用发布到 WebYou need to be a Microsoft Power BI user to use Publish to web. 你的报表(读取器、查看器)的使用者不需要是 Power BI 用户。The consumers of your report (the readers, 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 users on the Internet. 它是公开提供的,因此你可以期望将来查看者能够轻松地通过社交媒体共享报表。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 approach ensures the report can be viewed by thousands of concurrent users without any impact on 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 viewed by your users. 因此建议你提前暂存工作,并仅当你对设置满意时创建发布到 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.

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