How to get OData Connection Information

Get OData Connection Information

There might be cases where developers need to extract OData information from the excel file. Aspose.Cells for Python via .NET provides the Workbook.data_mashup property which returns the DataMashup information present in the Excel file. This information is represented by the DataMashup class. The DataMashup class provides the power_query_formulas property that returns the PowerQueryFormulaCollction collection. From the PowerQueryFormulaCollction, you can get access to PowerQueryFormula and PowerQueryFormulaItem.

The following code snippet demonstrates the use of these classes to retrieve the OData information.

The Source file used in the following code snippet is attached for your reference.

Source File

Sample Code

from aspose.cells import Workbook
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# source directory
SourceDir = RunExamples.Get_SourceDirectory()
workbook = Workbook(SourceDir + "ODataSample.xlsx")
PQFcoll = workbook.data_mashup.power_query_formulas
for PQF in PQFcoll:
print("Connection Name: " + PQF.name)
PQFIcoll = PQF.power_query_formula_items
for PQFI in PQFIcoll:
print("Name: " + PQFI.name)
print("Value: " + PQFI.value)

Console Output

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]