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-Java | |
// The path to the directories. | |
String sourceDir = Utils.Get_SourceDirectory(); | |
Workbook workbook = new Workbook(sourceDir + "ODataSample.xlsx"); | |
PowerQueryFormulaCollction PQFcoll = workbook.getDataMashup().getPowerQueryFormulas(); | |
for (Object obj : PQFcoll) | |
{ | |
PowerQueryFormula PQF = (PowerQueryFormula)obj; | |
System.out.println("Connection Name: " + PQF.getName()); | |
PowerQueryFormulaItemCollection PQFIcoll = PQF.getPowerQueryFormulaItems(); | |
for (Object obj2 : PQFIcoll) | |
{ | |
PowerQueryFormulaItem PQFI = (PowerQueryFormulaItem)obj2; | |
System.out.println("Name: " + PQFI.getName()); | |
System.out.println("Value: " + PQFI.getValue()); | |
} | |
} |
コンソール出力
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]