Hur man får OData anslutningsinformation
Få OData-anslutningsinformation
Det kan finnas fall där utvecklare behöver extrahera OData-information från Excel-filen. Aspose.Cells tillhandahåller egenskapen Workbook.DataMashup som returnerar DataMashup-informationen som finns i Excel-filen. Denna information representeras av klassen DataMashup. Klassen DataMashup tillhandahåller egenskapen PowerQueryFormulas som returnerar samlingen PowerQueryFormulaCollction. Från PowerQueryFormulaCollction kan du få tillgång till PowerQueryFormula och PowerQueryFormulaItem.
Följande kodsnutt visar användningen av dessa klasser för att hämta OData-informationen.
Källfilen som används i den följande kodsnutten bifogas för din 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); | |
} | |
} |
Konsoloutput
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]