OData接続情報を取得する方法
OData接続情報を取得
開発者がExcelファイルからOData情報を抽出する必要がある場合があります。Aspose.Cellsは、Excelファイルに存在するDataMashup情報を返す Workbook.DataMashup プロパティを提供します。この情報は DataMashup クラスによって表されます。DataMashup クラスは PowerQueryFormulas プロパティを提供し、 PowerQueryFormulaCollction コレクションを返します。 PowerQueryFormulaCollction から、 PowerQueryFormula と PowerQueryFormulaItem にアクセスできます。
次のコードスニペットは、これらのクラスを使用してOData情報を取得する方法を示しています。
以下のコードスニペットで使用されるソースファイルは参照用に添付されています。
サンプルコード
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// source directory | |
string SourceDir = RunExamples.Get_SourceDirectory(); | |
Workbook workbook = new Workbook(SourceDir + "ODataSample.xlsx"); | |
PowerQueryFormulaCollection PQFcoll = workbook.DataMashup.PowerQueryFormulas; | |
foreach (PowerQueryFormula PQF in PQFcoll) | |
{ | |
Console.WriteLine("Connection Name: " + PQF.Name); | |
PowerQueryFormulaItemCollection PQFIcoll = PQF.PowerQueryFormulaItems; | |
foreach (PowerQueryFormulaItem PQFI in PQFIcoll) | |
{ | |
Console.WriteLine("Name: " + PQFI.Name); | |
Console.WriteLine("Value: " + PQFI.Value); | |
} | |
} |
コンソール出力
Connection Name: Orders
Name: Source
Value: OData.Feed("https://services.odata.org/V3/Northwind/Northwind.svc/", null, [Implementation="2.0"])
Name: Orders_table
Value: Source{[Name="Orders",Signature="table"]}[Data]