Download, Print option in PowerBI embedded report with Angular7

送分小仙女□ 提交于 2019-12-04 21:00:58

You can print the report by calling report.print():

var element = document.getElementById('#myReport');
var report = powerbi.get(element);

report.print()
  .catch(error => { ... });

See Print a report in the official docs too. This will show the Print dialog, but the result isn't nice. Usually through printing you can create PDF file too, because there is no way to export a report as file (PDF, PowerPoint) using the API. SaveAs will allow you to make a copy of the report in the service, not as a file on the local disk.

// Get a reference to the embedded report HTML element
var embedContainer = $('#embedContainer')[0];

// Get a reference to the embedded report.
report = powerbi.get(embedContainer);

var saveAsParameters = {
    name: "newReport"
};

// SaveAs report
report.saveAs(saveAsParameters);

I have implemented this below code in angular 6

// Import powerbi-client

import * as pbi from 'powerbi-client';

// Variable declaration

let reportPrint;

//Inside the print function

let reportContainer = <HTMLElement>document.getElementById('reportContainer');
let powerbi = new 
pbi.service.Service(pbi.factories.hpmFactory,pbi.factories.wpmpFactory, 
pbi.factories.routerFactory);
this.reportPrint = powerbi.get(reportContainer);

this.reportPrint.print().catch(error => {  
    console.log(error);
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!