Node.js ve C++ kullanarak OData Bağlantı Bilgisi Nasıl Alınır
Contents
[
Hide
]
OData Bağlantı Bilgilerini Alın
Bazı durumlarda, geliştiricilerin Excel dosyasından OData bilgisini çıkarması gerekebilir. Aspose.Cells for Node.js via C++, Excel dosyasında bulunan DataMashup bilgisini döndüren Workbook.getDataMashup() özelliği sağlar. Bu bilgi DataMashup sınıfı ile temsil edilir. DataMashup sınıfı, DataMashup.getPowerQueryFormulas() özelliği sayesinde PowerQueryFormulaCollection koleksiyonunu döndürür. PowerQueryFormulaCollection öğesinden PowerQueryFormula ve PowerQueryFormulaItem erişebilirsiniz.
Aşağıdaki kod parçası, bu sınıfları kullanarak OData bilgisini almayı göstermektedir.
Aşağıdaki kod parçasında kullanılan Kaynak dosyası, referansınız için ekte bulunmaktadır.
Örnek Kod
const path = require("path");
const AsposeCells = require("aspose.cells.node");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "ODataSample.xlsx");
// Loads the workbook which contains hidden external links
const workbook = new AsposeCells.Workbook(filePath);
const PQFcoll = workbook.getDataMashup().getPowerQueryFormulas();
for (let i = 0; i < PQFcoll.getCount(); i++) {
const PQF = PQFcoll.get(i);
console.log("Connection Name: " + PQF.getName());
const PQFIcoll = PQF.getPowerQueryFormulaItems();
for (let j = 0; j < PQFIcoll.getCount(); j++) {
const PQFI = PQFIcoll.get(j);
console.log("Name: " + PQFI.getName());
console.log("Value: " + PQFI.getValue());
}
}
Konsol Çıktısı
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]