Forum Discussion
Anonymous
7 years agoNot applicable
Download Power BI report in code
Hi everyone, Is it possible to download a Power BI report in code (C# for example)? We would like to automate a download of a existing Power BI Report. Thank you in advance for your feedback...
- 7 years ago
Sorry I misunderstood.
Currently, the only support for export-to-pdf is in Power BI Desktop and not in the Power BI Service. Unfortunately, there is no way to automate generating PDF files with Power BI Desktop. I do not think what you want will be possible until the Power BI team adds export-to-pdf capabilities to the Power BI Service and also support to call it through the API. This feature is on the Power BI team's roadmap but I have no idea when we might see this in preview.
TedPattison
7 years agoMicrosoft Employee
Yes, you can use the Power BI SDK which provides methods in PowerBiClient.Reports. Here is an example.
PowerBIClient pbiClient = GetPowerBiClient();
var reportStream = pbiClient.Reports.ExportReportInGroup(appWorkspaceId, report.Id); string filePath = @"C:\tempExport\" + report.Name + ".pbix"; FileStream stream1 = new FileStream(filePath, FileMode.Create, FileAccess.ReadWrite); reportStream.CopyToAsync(stream1).Wait(); reportStream.Close(); stream1.Close(); stream1.Dispose();