如何获取OData连接信息
Contents
[
Hide
]
获取OData连接信息
开发者有时可能需要从Excel文件中提取OData信息。Aspose.Cells for Python via .NET 提供了Workbook.data_mashup属性,该属性返回Excel文件中的DataMashup信息。这些信息由DataMashup类表示。DataMashup类提供了power_query_formulas属性,该属性返回PowerQueryFormulaCollction集合。通过PowerQueryFormulaCollction,可以访问PowerQueryFormula和PowerQueryFormulaItem。
以下代码片段演示了使用这些类来检索OData信息。
以下代码片段中使用的源文件,请参考附件。
示例代码
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
控制台输出
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]