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.DataMashup egenskap som returnerar DataMashup-informationen som finns i Excel-filen. Denna information representeras avDataMashup klass. DeDataMashupklass gerPowerQueryFormulas egendom som returnerarPowerQueryFormulaCollection samling. FrånPowerQueryFormulaCollection, kan du få tillgång tillPowerQueryFormula ochPowerQueryFormulaItem.
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-.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); | |
} | |
} |
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]