Hur man får information om OData-anslutning
Få information om OData-anslutning
Det kan finnas fall där utvecklare behöver extrahera OData-information från excel-filen. Aspose.Cells tillhandahållerArbetsbok.DataMashupegenskap som returnerar DataMashup-informationen som finns i Excel-filen. Denna information representeras av DataMashup-klassen. Klassen DataMashup tillhandahåller egenskapen PowerQueryFormulas som returnerar samlingen PowerQueryFormulaCollction. Från PowerQueryFormulaCollction kan du få tillgång till PowerQueryFormula och PowerQueryFormulaItem.
Följande kodavsnitt visar användningen av dessa klasser för att hämta OData-informationen.
Källfilen som används i följande kodavsnitt bifogas som referens.
Exempelkod
// 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()); | |
} | |
} |
Konsolutgång
Anslutningsnamn: Beställningar
Namn: Källa
Värde: OData.Feed(“https://services.odata.org/V3/Northwind/Northwind.svc/", null, [Implementation=“2.0”])
Namn: Order_table
Värde: Källa{[Name=“Orders”,Signature=“table”]}[Data]