如何生成powerbi embedded报表的PDF输出
How to generate PDF output of powerbi embedded report
我的网页中嵌入了一份 powerbi 报告。我需要的是向我的页面添加一个 "export" 按钮,并在单击该按钮时将报告导出为 PDF。我怎样才能做到这一点?网上的人建议使用 report.print()
或 window.print()
,但两者都不适合我。
var reportContainer = document.getElementById('reportContainer');
var report = powerbi.embed(reportContainer, config);
var report2 = powerbi.get(reportContainer);
console.log(report); --returns the report
console.log(report2); --also returns the report
report.print(); --nothing happens
report2.print(); --nothing happens
var saveAsParameters = {
name: "newReport"
};
report2.saveAs(saveAsParameters); --nothing happens report.saveas also nothing happens
window.print(); --it prints a blank page.
我找到了这个但没有帮助:Print/Generate PDF of embedded power bi report
请注意,我知道我可以通过 PowerBI Desktop 将报告导出为 pdf,但我需要在我的自定义网页上执行此操作。
如有任何帮助,我们将不胜感激。
看起来很快就会作为 API 的一部分提供(2020 年 2 月之后)。
https://docs.microsoft.com/en-us/power-platform-release-plan/2019wave2/business-intelligence/api-export-report-powerpoint-pdf-jpeg
Developers will be able to provide their users with the option to export their data in PowerPoint, PDF, and JPEG formats in two main scenarios:
Interactive mode: End users interact with a report and export their own view of the data.
Non-interactive mode: Offline generation of snapshots distributed to different people in the organization.
The following capabilities will be supported:
Export report for both Power BI and non-Power BI users (SaaS and PaaS embed scenarios)
Export user context (the screenshot will include applied filters, cross filters, etc.)
Export including row-Level security (RLS)
Export a single page or entire report
您可以为您的消费者提供打印报告。每当您打印时,都可以选择以 pdf 格式下载。所以你可以通过打印的方式来解决这个问题。
这可以通过使用 Power BI Javascript API 轻松实现。
首先创建一个 HTML 按钮,允许用户单击以打印他们的报告。
<button id="theClick" onclick="print()">Print</button>
获得按钮后,为它添加 javascript。
function print() {
var element = $('#report-container')[0];
var report = powerbi.get(element);
report.print();
}
更多信息,您可以阅读微软官方文档:https://docs.microsoft.com/en-us/javascript/api/overview/powerbi/embedding-basic-interactions。
我的网页中嵌入了一份 powerbi 报告。我需要的是向我的页面添加一个 "export" 按钮,并在单击该按钮时将报告导出为 PDF。我怎样才能做到这一点?网上的人建议使用 report.print()
或 window.print()
,但两者都不适合我。
var reportContainer = document.getElementById('reportContainer');
var report = powerbi.embed(reportContainer, config);
var report2 = powerbi.get(reportContainer);
console.log(report); --returns the report
console.log(report2); --also returns the report
report.print(); --nothing happens
report2.print(); --nothing happens
var saveAsParameters = {
name: "newReport"
};
report2.saveAs(saveAsParameters); --nothing happens report.saveas also nothing happens
window.print(); --it prints a blank page.
我找到了这个但没有帮助:Print/Generate PDF of embedded power bi report
请注意,我知道我可以通过 PowerBI Desktop 将报告导出为 pdf,但我需要在我的自定义网页上执行此操作。
如有任何帮助,我们将不胜感激。
看起来很快就会作为 API 的一部分提供(2020 年 2 月之后)。
https://docs.microsoft.com/en-us/power-platform-release-plan/2019wave2/business-intelligence/api-export-report-powerpoint-pdf-jpeg
Developers will be able to provide their users with the option to export their data in PowerPoint, PDF, and JPEG formats in two main scenarios:
Interactive mode: End users interact with a report and export their own view of the data.
Non-interactive mode: Offline generation of snapshots distributed to different people in the organization.The following capabilities will be supported:
Export report for both Power BI and non-Power BI users (SaaS and PaaS embed scenarios)
Export user context (the screenshot will include applied filters, cross filters, etc.)
Export including row-Level security (RLS)
Export a single page or entire report
您可以为您的消费者提供打印报告。每当您打印时,都可以选择以 pdf 格式下载。所以你可以通过打印的方式来解决这个问题。
这可以通过使用 Power BI Javascript API 轻松实现。
首先创建一个 HTML 按钮,允许用户单击以打印他们的报告。
<button id="theClick" onclick="print()">Print</button>
获得按钮后,为它添加 javascript。
function print() {
var element = $('#report-container')[0];
var report = powerbi.get(element);
report.print();
}
更多信息,您可以阅读微软官方文档:https://docs.microsoft.com/en-us/javascript/api/overview/powerbi/embedding-basic-interactions。