1

目标:在powerbi api javascript的帮助下,将分页报告加载到参数很少的网页中。

分页reportUrl: https ://app.powerbi.com/groups/workspaceId/rdlreports/reportId?ctid=something&rp:CustomerID=something&rp:ContractID=something

我可以加载报告但无法传递参数 - 因此报告加载为空白。

与 powerbi 报表不同,分页报表不支持像 powerBi 嵌入式报表那样的 report.getFilters()。

我参考了这些文档-但找不到任何帮助...

https://docs.microsoft.com/en-us/power-bi/paginated-reports-parameters https://docs.microsoft.com/en-us/power-bi/developer/paginated-reports-row-level -security#passing-the-configured-parameter-using-the-embed-token https://docs.microsoft.com/en-us/power-bi/developer/embed-paginated-reports-customers

这就是我获取 powerbi 报告然后将其嵌入网页的方式:

[HttpGet]
    [Route("AccessToken")]
    [ProducesResponseType(StatusCodes.Status200OK)]
    public async Task<ActionResult> GetEmbeddedAccessTokenAsync(string reportType)
    {            

        Guid currentReportId = getCurrentReportId(reportType); //private method which gets the report guid

        using (var client = await GetPowerBIClientAsync())
        {                
            var report = await client.Reports.GetReportInGroupAsync(_powerBiWorkspaceId, currentReportId);
        


            var generateTokenRequestParameters = new GenerateTokenRequest(accessLevel: TokenAccessLevel.View);

            var tokenResponse = await client.Reports.GenerateTokenInGroupAsync(_powerBiWorkspaceId, report.Id, generateTokenRequestParameters);
            
            return new OkObjectResult(JsonSerializer.Serialize(new { EmbedUrl = report.EmbedUrl, AccessToken = tokenResponse.Token, WorkspaceId = _powerBiWorkspaceId, ReportId = report.Id, Expires = tokenResponse.Expiration }));
        }
    }
    
    
    let token = await this.http.get(this.url + 'api/PowerBi/AccessToken?reportType=' + this.reportType, { params: {}, responseType: 'text', withCredentials: true }).toPromise();
    let tokenObject = JSON.parse(token);
    let reportContainer = document.getElementById('kpi-report-container');
    this.powerbi.bootstrap(reportContainer, config);
    let report: Report = <Report>(this.powerbi.embed(reportContainer, config));
    
    // Report.off removes a given event handler if it exists.        
    report.off("loaded");
    let self = this;
    // Report.on will add an event handler which prints to Log window.
    report.on("loaded", function () {
      self.SelectedReportId(self.reportId);
      report.updateSettings({
        bookmarksPaneEnabled: false,
        filterPaneEnabled: true
      });
      // Set token expiration listener
      self.SetTokenExpirationListener(tokenObject.Expires,
        2, /*minutes before expiration*/
        tokenObject.ReportId,
        tokenObject.WorkspaceId);
    });
4

1 回答 1

5

我们可以通过将参数与嵌入 URL 连接起来,将 URL 参数传递到嵌入的分页报告中。

例如:如果我们有一个名为“Salesperson”的参数,其中一个值为“Brownie”,那么我们可以通过将其连接到报表配置中报表的嵌入 URL 中来过滤分页报表:embedUrl + "&rp:Salesperson =布朗尼”

上面的 embedUrl 将根据给定的参数过滤嵌入的分页报告。

您可以参考此博客链接以获取更多信息。

于 2020-11-25T05:59:34.737 回答