使用 Angular7 在 PowerBI 嵌入式报告中下载、打印选项 [英] Download, Print option in PowerBI embedded report with Angular7

查看:14
本文介绍了使用 Angular7 在 PowerBI 嵌入式报告中下载、打印选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了 PowerBI 报告,并通过向 Azure Active Directory (AAD) 注册应用程序将其嵌入到我的 angular7 客户端应用程序中.它完美嵌入.我想允许我的客户端应用程序的用户下载和打印该嵌入式报告.以下是我嵌入 PowerBI 报告的 Angulr7 代码.

I have created PowerBI report and It has been embedded to my angular7 client application by registering the application with Azure Active Directory(AAD). It embeds perfectly. I want to allow that embedded report to be downloaded, printed by the user of my client application. Following is my Angulr7 code to embed the PowerBI report.

      showReport() {
    // Report's Secured Token
    let accessToken = 'myAccessToken';
    // Embed URL
    let embedUrl = 'embedUrl';
    // Report ID
    let embedReportId = 'embedReportId';
    let config = {
      type: 'report',
      accessToken: accessToken,
      embedUrl: embedUrl,
      id: embedReportId,
      settings: {
        localeSettings: {
          language: "en",
          formatLocale: "es"
        }
      }
    };
    // Grab the reference to the div HTML element that will host the report.
    let reportContainer = <HTMLElement>document.getElementById('reportContainer');
    // Embed the report and display it within the div container.
    let powerbi = new pbi.service.Service(pbi.factories.hpmFactory, pbi.factories.wpmpFactory, pbi.factories.routerFactory);
    let report = powerbi.embed(reportContainer, config);
    var rep = powerbi.get(reportContainer);
    // Report.off removes a given event handler if it exists.
    report.off("loaded");
    // Report.on will add an event handler which prints to Log window.
    report.on("loaded", function () {
      console.log("Loaded");
    });
  }

我怎样才能做到这一点?

How can I achieve this?

推荐答案

我已经在 Angular 6 中实现了下面的代码

I have implemented this below code in angular 6

//导入powerbi-client

// Import powerbi-client

import * as pbi from 'powerbi-client';

//变量声明

let reportPrint;

//打印函数内部

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);
});

这篇关于使用 Angular7 在 PowerBI 嵌入式报告中下载、打印选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆