用于 .NET 的 Power BI Embedded 库
Power BI 是基于云的业务分析服务,可提供最关键业务数据的单一视图。
若要详细了解如何在 .NET 中使用 Power BI,请参阅 Power BI 的嵌入功能。
客户端库
使用客户端库来连接 Power BI API,以访问数据集和报表并与其交互。
直接从 Visual Studio 包管理器控制台安装 NuGet 包。
Visual Studio 包管理器
Install-Package Microsoft.PowerBI.Api
示例
以下示例检索并显示数据集和报表的列表。
/* Include these'using' directive:
using Microsoft.PowerBI.Api.V2;
using Microsoft.PowerBI.Api.V2.Models;
*/
using (PowerBIClient client = new PowerBIClient(new Uri(apiUrl), tokenCredentials))
{
Console.WriteLine("\r*** DATASETS ***\r");
// List of datasets in a group/app workspace
ODataResponseListDataset datasetList = client.Datasets.GetDatasetsInGroup(groupId);
foreach(Dataset ds in datasetList.Value)
{
Console.WriteLine(ds.Id + " | " + ds.Name);
}
Console.WriteLine("\r*** REPORTS ***\r");
// List of reports in a group/app workspace
ODataResponseListReport reportList = client.Reports.GetReportsInGroup(groupId);
foreach (Report rpt in reportList.Value)
{
Console.WriteLine(rpt.Id + " | " + rpt.Name + " | DatasetID = " + rpt.DatasetId);
}
}
示例
详细了解可在应用中使用的示例 .NET 代码。